I am trying to highlight the row of the datagrid that contains a specific value in a field. The datagrid has the ListBoxSelection set to One. The grid also has code for the currentcellmoving and currentcellactivating which set the column to column 0.
The code which is failing looks like this...
intSelectedRow = 0
intRow = 1
Do While intRow < grid1.RowCount
If grid1(intRow, 1).CellValue = strVehicleId
intSelectedRow = intRow
intRow = intRow + 1
If intSelectedRow <> 0 Then
Me.grid1.CurrentCell.MoveTo(intSelectedRow, 0, GridSetCurrentCellOptions.SetFocus Or GridSetCurrentCellOptions.ScrollInView, False)
The loop that searches for the value in column 1 works because the intSelectedRow value is set to a value other that zero. However, the call to highlight the row is not working.
I also tried a variation in which I move to the cell and then invoked a single click, but that did not work either.
Me.grid1.CurrentCell.MoveTo(intSelectedRow, 0) Me.grid1.ActivateCurrentCellBehavior = GridCellActivateAction.ClickOnCell
Any suggestions would be greatly appreciated. Thank you for your help.
ADAdministrator Syncfusion Team April 16, 2003 09:22 AM
Where are you trying to do this?
If it is before the grid has been drawn, so in FormLoad, then try setting this property to see if that will allow things to work.
this.gridControl1.ForceCurrentCellMoveTo = true;
CJClifton JonesApril 16, 2003 09:40 AM
> Where are you trying to do this?
> If it is before the grid has been drawn, so in FormLoad, then try setting this property to see if that will allow things to work.
> this.gridControl1.ForceCurrentCellMoveTo = true;
The code is in the Form load event. Your suggestion worked.