|
Private Sub
OnChangeCellValueClicked(ByVal sender As Object, ByVal e As System.EventArgs)
' Check the view is not null and the table
control is not null
If
sfDataGrid1.View IsNot Nothing AndAlso sfDataGrid1.TableControl IsNot Nothing AndAlso sfDataGrid1.View.Records
IsNot Nothing Then
' Loop through the all records
in the view based on Grouping applied or not and set the value for particular
column in the record
For i As Integer = 1 To (If(sfDataGrid1.View.TopLevelGroup IsNot Nothing,
sfDataGrid1.View.TopLevelGroup.DisplayElements.Count,
sfDataGrid1.View.Records.Count))
' Get the row index based on
the record index
Dim recordIndex =
sfDataGrid1.TableControl.ResolveToRecordIndex(i)
If
recordIndex < 0 Then
Continue For
End If
Dim record As Object = Nothing
' Get the record when grouping
applied in SfDataGrid
If
sfDataGrid1.View.TopLevelGroup IsNot Nothing Then
Dim
displayElement = sfDataGrid1.View.TopLevelGroup.DisplayElements(recordIndex)
If
displayElement Is Nothing Then
Continue For
End If
If TypeOf
displayElement Is
RecordEntry Then
record = CType(displayElement,
RecordEntry).Data
End If
Else '
Get the record when grouping is not applied in SfDataGrid
record =
sfDataGrid1.View.Records(recordIndex).Data
End If
'Change the cell value for
particular column (Discount1) in the record
If
record IsNot Nothing Then
sfDataGrid1.View.GetPropertyAccessProvider().SetValue(record,
"Discount1", "75")
End If
Next i
End If
End Sub
|