Home Forums WinForms controls Xceed Grid for WinForms UpdateDetailGrids caused value to be reset Reply To: UpdateDetailGrids caused value to be reset

User (Old forums)
Member
Post count: 23064

I still do not know where to put the leaveedit(true) command? My codes is as below, do you mind to show me where should I put this command in the below code?

——————————————————————————————————
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

GridControl1.BeginInit()
Dim columnNo As New Xceed.Grid.Column(“Col1”)
GridControl1.Columns.Add(columnNo)
GridControl1.FixedHeaderRows.Add(New Xceed.Grid.ColumnManagerRow())

Dim detailGrid As New DetailGrid()

detailGrid.HeaderRows.Add(New ColumnManagerRow())
detailGrid.Columns.Add(New Column(“DetailCol1”))

GridControl1.DetailGridTemplates.Add(detailGrid)
AddHandler GridControl1.InitializingDetailGrid, AddressOf Me.init_DetailGrid
GridControl1.EndInit()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If GridControl1.DetailGridTemplates(0).Collapsed Then
GridControl1.DetailGridTemplates(0).Expand()
Else
GridControl1.DetailGridTemplates(0).Collapse()
End If
GridControl1.UpdateDetailGrids()

End Sub

Private Sub init_init_DetailGrid(ByVal sender As Object, ByVal e As InitializingDetailGridEventArgs)

Dim row As Xceed.Grid.DataRow
row = e.Grid.DataRows.AddNew()
row.Cells(“DetailCol1”).Value = “AAA”
AddHandler row.CellValueChanged, AddressOf Me.Cell_ValueChanged
row.EndEdit()

End Sub

Private Sub Cell_ValueChanged(ByVal sender As Object, ByVal e As EventArgs)
” some calculations here
End Sub
——————————————————————————————————

Should it be under Sub Cell_ValueChanged or Sub Button1_Click? I tried putting “CType(sender, Xceed.Grid.DataCell).LeaveEdit(True)” in the sub Cell_ValueChanged but it doesn’t work. Or should it be a seperate handler? If yes then how? Appreciate if you can provide me with some code.

Many thanks

Imported from legacy forums. Posted by CI (had 440 views)