possible bug in TWebStringGrid

I have a TWebStringGrid that I fill at run-time. No matter where the user clicks on it, the first data row is always considered "selected". Meaning, if the user clicks on row #5, the OnSelectCell gets passed Row=1, even though row#5 is highlighted. (I have RowSelect enabled.)

The problem is, there's no "Selected" property, nor is there an "OnSelected" event.

It's ok if the first row is selected by default, but since there's no "Selected" property, you don't know. You need to track the currently selected row using the OnSelectCell handler (at least, that's all I've found). The first click ALWAYS selects the FIRST ROW, but another row may well be highlighted.

It needs a "Selected" property added. as well a a way to assign that from code. Right now, it's only set by a UI request.

We've seen an intermediate OnSelectCell event triggered (caused by the table getting focus for the first time, where it is assumed that when the grid just gets focused, it will select the first row).
But after this OnSelectCell, there is a final OnSelectCell with the final row that will be selected.
We improved the grid to avoid that intermediate OnSelectCell() and this improvement will be in the next release.
About programmatically getting or setting the selected row when goRowSelect = true in grid.Options, that can be done via the grid.Row: integer property.

Ahh, good to know it has been found.

Do you mean simply assigning to the Row property will select it?

grid.Row := 5;
should do it.

1 Like

I see that it selects the row, but does not trigger any Selection event.

Is that intentional?

Perhaps you can add a SelectCell( aCol, aRow : integer ) method that sets the row and triggers the OnSelectCell event? And maybe SelectRow( aRow ) and SelectCol( aCol ) ?

It is by design that programmatic settings do not trigger events.