Recent

Author Topic: How to deselect/unselect stringgrid row/cell ??  (Read 20969 times)

Batuhan

  • New Member
  • *
  • Posts: 14
How to deselect/unselect stringgrid row/cell ??
« on: May 05, 2009, 04:39:25 pm »
Hi!

How to deselect/unselect stringgrid row/cell ??

I have StringGrid with Rowselect set to 'True', my procedure:

procedure TMainForm.StringGrid1DblClick(Sender: TObject);
 var
   point: TPoint;
   coord : TGridCoord; 
 begin
   point:= StringGrid1.ScreenToClient(Mouse.CursorPos);
   coord:= StringGrid1.MouseCoord(point.X, point.Y);

  if coord.Y <> StringGrid1.RowCount-1 then
    ShowMessage('Col = ' + IntToStr(coord.X)+ ', Row = ' +inttostr(coord.Y))
       
    else
      // here I need deselecting/unselecting code...

end;

Thanks!


Batuhan

  • New Member
  • *
  • Posts: 14
Re: How to deselect/unselect stringgrid row/cell ??
« Reply #1 on: May 06, 2009, 09:52:11 pm »
for now i have working solution...

StringGrid1.Selection := TGridRect(Rect(-1, -1, -1, -1));
StringGrid1.Options:= StringGrid1.Options - [goRowSelect];

... but i'm still not satisfied  :(


cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: How to deselect/unselect stringgrid row/cell ??
« Reply #2 on: November 12, 2016, 05:43:22 am »
Sorry for this late response. To unselect previously selected stuff:

Code: Pascal  [Select][+][-]
  1. StringGrid1.ClearSelections;
  2. StringGrid1.Invalidate;

Note: In Lazarus 1.6 ClearSelection will not remove the gdSelected from the aState inside the OnDrawCell event. Is it a bug? Please make know and I will report it.
« Last Edit: November 12, 2016, 07:15:55 am by cpicanco »
Be mindful and excellent with each other.
https://github.com/cpicanco/

 

TinyPortal © 2005-2018