|
Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
' Get the cell value for RowIndex = 5 and ColumnIndex = 3
Dim rowIndex As Integer = 5
Dim columnIndex As Integer = sfDataGrid.TableControl.ResolveToGridVisibleColumnIndex(3)
If columnIndex < 0 Then
Return
End If
Dim mappingName = sfDataGrid.Columns(columnIndex).MappingName
Dim recordIndex = sfDataGrid.TableControl.ResolveToRecordIndex(rowIndex)
If recordIndex < 0 Then
Return
End If
If sfDataGrid.View.TopLevelGroup IsNot Nothing Then
Dim record = sfDataGrid.View.TopLevelGroup.DisplayElements(recordIndex)
If Not record.IsRecords Then
Return
End If
Dim data = (TryCast(record, RecordEntry)).Data
Dim cellVaue = (data.GetType().GetProperty(mappingName).GetValue(data, Nothing).ToString())
Else
Dim record1 = sfDataGrid.View.Records.GetItemAt(recordIndex)
Dim cellVaue = (record1.GetType().GetProperty(mappingName).GetValue(record1, Nothing).ToString())
End If
End Sub |
|
Private Sub button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handlesbutton2.Click
' Set the cell value for RowIndex = 2 and ColumnIndex = 1
Me.sfDataGrid.View.GetPropertyAccessProvider().SetValue(sfDataGrid.GetRecordAtRowIndex(2), sfDataGrid.Columns(1).MappingName, "Syncfusion")
End Sub |
|
AddHandler Me.sfDataGrid.AddNewRowInitiating, AddressOf sfDataGrid_AddNewRowInitiating
Private Sub sfDataGrid_AddNewRowInitiating(ByVal sender As Object, ByVal e As Syncfusion.WinForms.DataGrid.Events.AddNewRowInitiatingEventArgs)
Dim data = TryCast(e.NewObject, OrderInfo)
data.OrderID = 101
End Sub |
|
AddHandler Me.sfDataGrid.AddNewRowInitiating, AddressOf sfDataGrid_AddNewRowInitiating
Private Sub sfDataGrid_AddNewRowInitiating(ByVal sender As Object, ByVal e As Syncfusion.WinForms.DataGrid.Events.AddNewRowInitiatingEventArgs)
Dim data = TryCast(e.NewObject, System.Data.DataRowView)
data.Row("ID") = 1010
data.Row("Name") = "James"
End Sub |