The Syncfusion® native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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
Then
intSelectedRow = intRow
Exit Do
End If
intRow = intRow + 1
Loop
If intSelectedRow <> 0 Then
Me.grid1.Focus()
Me.grid1.CurrentCell.MoveTo(intSelectedRow, 0, GridSetCurrentCellOptions.SetFocus Or GridSetCurrentCellOptions.ScrollInView, False)
End If
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.Focus()
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 01:22 PM UTC
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 01:40 PM UTC
> 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.
Thanks