We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Trying to highlight a row programatically

Thread ID:

Created:

Updated:

Platform:

Replies:

3883 Apr 16,2003 05:03 AM Apr 16,2003 09:40 AM Windows Forms 2
loading
Tags: GridControl
Clifton Jones
Asked On April 16, 2003 05:03 AM

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.

Administrator [Syncfusion]
Replied On 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;

Clifton Jones
Replied On April 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. Thanks

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;