Get Cell Value in GDBG control

I need to get the value of a cell from the current row. I want to use the name of the column because the users move them around. I'm using this method and it works fine until the column is moved. I want to replace the call to the datarow object (dr)

Dim cc As GridCurrentCell = dgEng.CurrentCell
Dim cm As CurrencyManager = CType Me.BindingContext(Me.dgEng.DataSource, Me.dgEng.DataMember), CurrencyManager)

Dim dr As DataRow = CType(cm.Current, DataRowView).Row

dgEng(cc.RowIndex, dr.Table.Columns("PlatMap").Ordinal + 1).Text

Thanks

1 Reply

AD Administrator Syncfusion Team February 28, 2007 08:57 PM UTC

Hi Prumery,

You can get the ColIndex from column name by using Binder.NameToColIndex method. Please try the code snippet

Dim cc As GridCurrentCell = dgEng.CurrentCell
Dim cm As CurrencyManager = CType Me.BindingContext(Me.dgEng.DataSource, Me.dgEng.DataMember), CurrencyManager)
Dim dr As DataRow = CType(cm.Current, DataRowView).Row
Dim ColIndex As Integer = dgEng.Binder.NameToColIndex("PlatMap")
dgEng(cc.RowIndex, ColIndex).Text

Best regards,
Haneef

Loader.
Up arrow icon