Jump to content


Photo

Putting focus back on selected row?


  • Please log in to reply
2 replies to this topic

#1 littlebigfred

littlebigfred
  • Members
  • 176 posts

Posted 27 October 2008 - 10:09 PM

Hello

After the user has double-clicked on a row in a NextGrid object, I display fields in a two-column grid in a modal form to let him make changes, and then go back to to the main form.

I'd like to display the original row selected, so that the user sees which row he selected before. This doesn't work:

CODE
procedure TForm1.Button2Click(Sender: TObject);
begin
  for i := 0 to NextGrid1.RowCount - 1 do begin
    if NextGrid1.Selected[i] then begin
        Form2.ShowModal;

        //Put focus back on selected row
        //Doesn't work NextGrid1.Selected[i] := True;

        Break;
    end;
  end;
end;


Thank you.

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 27 October 2008 - 11:12 PM

Hello Littlebigfred,

Try to use NextGrid1.Selected row := <someindex>

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 Thrawn123

Thrawn123
  • Members
  • 18 posts

Posted 07 November 2008 - 12:22 AM

QUOTE (littlebigfred @ Oct 27 2008, 02:09 PM) <{POST_SNAPBACK}>
Hello

After the user has double-clicked on a row in a NextGrid object, I display fields in a two-column grid in a modal form to let him make changes, and then go back to to the main form.

I'd like to display the original row selected, so that the user sees which row he selected before. This doesn't work:

CODE
procedure TForm1.Button2Click(Sender: TObject);
begin
  for i := 0 to NextGrid1.RowCount - 1 do begin
    if NextGrid1.Selected[i] then begin
        Form2.ShowModal;

        //Put focus back on selected row
        //Doesn't work NextGrid1.Selected[i] := True;

        Break;
    end;
  end;
end;


Thank you.



After doing the selection in code, I've found that I've had to do NextGrid1.Repaint;
What seems to be happening (in my case anyway) is that the row is getting selected in code, but not being shown as selected on screen until you force a repaint of the grid.
Hope that helps...




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users