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. Image for the cookie policy date

GC: Setting the currrent row

Hi

Simple question:
How do I set the current selected row in a GridControl? A property such as GridControl.CurrentRow = 3 would be great. I'm using the following code but I end up with 1 row being selected and another being the current cell. Must be an easier way than this!

Public Sub SetRowAsCurrent(ByVal rowIndex As Integer)

If rowIndex < m_Grid.Rows.HeaderCount Or rowIndex > m_Grid.RowCount Then
Exit Sub
End If

'clear any selected ranges
m_Grid.Selections.Clear(False)

m_Grid.Selections.Add(GridRangeInfo.Row(rowIndex))

m_Grid.Selections.CurrentCellInfo.RowIndex = rowIndex

End Sub


4 Replies

RB Richard Bysouth July 11, 2007 06:57 AM UTC

that last line was wrong, should have been

m_Grid.CurrentCellInfo.RowIndex = rowIndex

Do I have to set both CurrentCellInfo.RowIndex AND add the row to the Selections?

I only want to select a single row!


HA haneefm Syncfusion Team July 11, 2007 06:27 PM UTC

Hi Richard,

You can try these code :

this.gridControl1.CurrentCell.MoveTo(2, 2);
this.gridControl1.Model.Selections.Add(GridRangeInfo.Row(2));

Best regards,
Haneef


RB Richard Bysouth July 11, 2007 09:58 PM UTC

thanks Haneef

Sorry to ask such simple questions, but how do I retrieve the current rowIndex?
I have tried many many properties such as CurrentCell.RowIndex, CurrentCell.MoveFromRowIndex etc. but none of these return the correct row index!

Is there some documentation somewhere outlining the differences between all of the CurrentCell/Selections/Ranges properties? Couldn't find anything in the Knowledge Base to help me

many thanks

Richard


HA haneefm Syncfusion Team July 12, 2007 08:52 PM UTC

Hi Richard,

How do I retrieve the current rowIndex?
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.

You can retrieve the current rowIndex by using the CurrentCell.RowIndex.But I am not sure of what be might be causing this strange behavior without a working sample. I have tested this issue in browser sample with Essentail studio V.4.x/5.x. But i was not able to reproduce the issue. Is it possible for you to upload us a minimal sample or modify the browser sample to reproduce the issue here? This will help us to analyse the issue further.

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon