Board index » delphi » Events from TStringGrid

Events from TStringGrid

Des anyone know what events are triggered when a user goes from Cell to cell
in this component. Secondly there is a cell that always has a blue box on it
. It is the last cell accessed. Does anyone know how to control this blue
box or how to get rid of it???

Thanks

Dave

 

Re:Events from TStringGrid


Quote
In article <3c7d56b6$1_1@dnews>,  wrote:
> Des anyone know what events are triggered when a user goes from Cell to cell
> in this component.

OnSelectCell is triggered for the target cell. In this event the grids Row and
Col property still refer to the previous cell, the aCol and aRow parameters to
the new cell.

Quote
> Secondly there is a cell that always has a blue box on it
> .. It is the last cell accessed. Does anyone know how to control this blue
> box or how to get rid of it???

This is the current cell, the one indexed by the grids Col and Row properties.
You can move it by setting Col and Row. Getting rid of the selection marker is
a bit more problematic. If the user has selected a range of cells they will
all appear in the blue color. In this case the grids Selection property tells
you the bounds of the selected area. You can also modify the selection by
changing the Selection property.

The most robust way to change the selection color or remove it (change the
selection color to the grids Color) is to attach a handler to the OnDrawCell
event and draw the cell yourself. You have to draw background and text.
If you search the archives for Stringgrid1DrawCell you should find many
examples of such a handler.

--
Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Re:Events from TStringGrid


Hi Dave,

In the stringgrid options their is a property for goDrawFocusSelected which
can be set to false which should remove the highlight color.  But if you
take the focus off of the stringgrid there still may be a highlight color on
the last cell in focus.  If this is the case create an on exit event like

procedure TForm1.StringGrid1Exit(sender:TObject);
const
    NoSelection:TGridRect=(Left:-1;Top:-1;Right:-1;Bottom:-1);
begin
    stringgrid1.selection:=NoSelection;
end;

This worked for me when I used three stringgrids and would change focus
between them

Shawn

P.S. Thomas Stutz helped me with this one so I'm just passing it on.

Quote
<d...@digitalks.com> wrote in message news:3c7d56b6$1_1@dnews...
> Des anyone know what events are triggered when a user goes from Cell to
cell
> in this component. Secondly there is a cell that always has a blue box on
it
> . It is the last cell accessed. Does anyone know how to control this blue
> box or how to get rid of it???

> Thanks

> Dave

Other Threads