Get RowIndex out of DataRow

Hello,

well I'm from Switzerland, so my english isn't very good.


So, I've a problem.

I'm looping through all the Rows in a DataTable to control the values of the cells. If a value isn't correct I want to apport and set the focus on this cell.
Well I allready found the function "


My code looks like that:
(I deleted many things, but you don't have to care about the rest)

---code---
Private Function ValidateRapportPos(ByVal oGrid As Syncfusion.Windows.Forms.grid.GridDataBoundGrid) As Boolean
Dim oRow As DataRow
Dim oDataTable As New DataTable
oDataTable = m_RppStunden

For Each oRow In oDataTable.Rows

If oRow(enColsGrd.Bezeichnung) <= 0 Then
m_sMsg = "error! bla bla bla!"

'Here i want to set the focus to the cell: oRow(enColsGrd.Bezeichnung) oGrid.CurrentCell.MoveTo(, enColsGrd.Bezeichnung)

Return False
End If

Next
---code---



thank you very much for helping me!


regards peter.

2 Replies

AD Administrator Syncfusion Team March 21, 2007 12:51 PM UTC

oh... there's a little mistake, it's quite difficult to write code in here... :)

'Here i want to set the focus to the cell: oRow(enColsGrd.Bezeichnung)
oGrid.CurrentCell.MoveTo(???, enColsGrd.Bezeichnung)

??? = RowIndex, but how can I get it, out of oRow?


AD Administrator Syncfusion Team March 21, 2007 07:55 PM UTC

Hi Peter,

Use the Binder.ListManagerPositionToRowIndex method to find a zero-based position of the data source displayed in the grid to an absolute row index in the grid. You can try the below code snippet to find a rowindex.

---code---
Private Function ValidateRapportPos(ByVal oGrid As Syncfusion.Windows.Forms.grid.GridDataBoundGrid) As Boolean
Dim oRow As DataRow
Dim oDataTable As New DataTable
Dim iPosition As Integer = 0
oDataTable = m_RppStunden

For Each oRow In oDataTable.Rows

If oRow(enColsGrd.Bezeichnung) <= 0 Then
m_sMsg = "error! bla bla bla!"
'Here i want to set the focus to the cell: oRow(enColsGrd.Bezeichnung) oGrid.CurrentCell.MoveTo(, enColsGrd.Bezeichnung)

Dim iRowIndex As Integer = oGrid.Binder.ListManagerPositionToRowIndex(iPosition)
oGrid.CurrentCell.MoveTo( iRowIndex , enColsGrd.Bezeichnung)

Return False
End If
iPosition ++
Next
---code---

Best Regards,
Haneef

Loader.
Up arrow icon