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

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #12941 |

    Hi all,

    I am developing a master detail grid. By default, the detail grid is in expand mode, I have a button which is used to trigger the collapse and expand method of the detail grid with the below codes:

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

    When the grid was being shown in the form (with the detail grid expand), I tried editing the cell values in the detail grid. Next I clicked on the the button to collapse it and click again to expand it, but now this time the value which I changed was being reset to the old value.

    I put in some debugging codes to check and realize that it’s only after the line “GridControl1.UpdateDetailGrids()”, then the value was reset to the old value.

    May I know how should I go about in resolving this?

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

    User (Old forums)
    Member
    Post count: 23064

    Did you leave edit mode on the cell before pressing you button?

    Imported from legacy forums. Posted by C# (had 275 views)

    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)

    User (Old forums)
    Member
    Post count: 23064

    If you press ENTER in a cell, then any changes should be automatic commited.
    Or if you leave the current row.

    Try editing a cell, then press enter, and then press the Button1.

    Imported from legacy forums. Posted by C# (had 306 views)

    User (Old forums)
    Member
    Post count: 23064

    or put this in you’r button event:
    (Before you collaps/expand the detailrows)

    if( gridControl1.CurrentRow != null && gridControl1.CurrentRow is Xceed.Grid.CellRow)
    {
    ((Xceed.Grid.CellRow)gridControl1.CurrentRow).EndEdit();
    }

    Imported from legacy forums. Posted by C# (had 279 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    I’ve the same situation,I’ve included the code in the button click. still i get the old state of the grid.

    TIA,
    s.

    Imported from legacy forums. Posted by paanis (had 5078 views)

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.