Jump to content


Photo

Grid selected[] strange behaviour


  • Please log in to reply
3 replies to this topic

#1 qwerty

qwerty
  • Members
  • 6 posts

Posted 28 August 2007 - 03:36 PM

Good day.

I need to implement feature like this. Just imagine.
You have a grid on your form. Than you click on field title and choose menu «Select similar». The grid looks what is the value in the active cell and must select all rows which have the same value in that field (loop by column).

After that if you press key arrows (change active row) selected items don't lose their states.

Here is the code to see that bug.
CODE
Grid.BeginUpdate;
for j := 0 to Grid.RowCount - 1 do begin
Grid.Selected[j] := true;
end;
Grid.EndUpdate;
Grid.SetFocus;


How to solve this?

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 28 August 2007 - 03:57 PM

Hello,

Please add one new procedure in NxCustomGridControl.pas (inside public section):

CODE
procedure TNxCustomGridControl.SetMultiSelected;
begin
  Include(FGridState, gtMultiSelect);
end;


Then, use next code:

CODE
procedure TForm1.Button1Click(Sender: TObject);
var
  j: Integer;
begin
  Grid.BeginUpdate;
  Grid.SelectedRow := 0; // <--- SelectedRow is -1 by default.
  for j := 0 to Grid.RowCount - 1 do begin
    Grid.Selected[j] := true;
  end;
  Grid.EndUpdate;
  Grid.SetFocus;
  Grid.SetMultiSelected;
end;


I hope that this helps. I will work to add some kind of automatic multi-selection when more than 1 row is selected from code.

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 qwerty

qwerty
  • Members
  • 6 posts

Posted 28 August 2007 - 04:42 PM

Thank you.

I suppose this procedure will be in next release.
Is it right?

#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 28 August 2007 - 04:46 PM

Hello,

Yes, it is already included.

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.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users