Home Forums WinForms controls Xceed Grid for WinForms commit changes made in a datagrid

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #15221 |

    I need to commit the changes a user makes on a datagrid to the underlying datatable (not to the database).

    This is the scenario:

    I have a dataset with a datatable (it is used only to establish selections, it has 4 columns and only 2 are not readonly), this then is bound to the datagrid.

    When a user changes the value of the “original” column to “1” it should change the value of the “copy” column to “0”. I have “tried” to do this using the “leavingedit” event, the problem is that the user “must” leave the “cell” or “row” in order to “see” the changes. (the same logic should be used for the “copy” column if it’s value is “1” then “original” column should be set to “0”)

    Private Sub celldataRowTemplate1Original_LeavingEdit(ByVal sender As Object, ByVal e As Xceed.Grid.LeavingEditEventArgs) Handles celldataRowTemplate1Original.LeavingEdit
    Dim xCell As Xceed.Grid.Cell = CType(sender, Xceed.Grid.Cell)

    If e.NewValue = 1 Then
    If xCell.ParentRow.Cells(“Copy”).Value = 1 Then
    xCell.ParentRow.Cells(“Copy”).Value = 0
    End If
    End If
    End Sub

    Now one more thing, and that’s where I’m stucked, If the user makes any change to any of the two columns “original” or “copy” and leaves the grid (moves to another control) the grid should make the changes to both columns and display the results (commit the changes).

    Any help will be appreciated. Thanx in advance

    Imported from legacy forums. Posted by cursositca (had 2081 views)

    User (Old forums)
    Post count: 23064

    First, to commit a row or a cell value, the user must leave the editing mode. That is a normal behavior. It you want to change this behavior, you can monitor the text that is typed by the user in the cell, and then make the changes you wish accordingly.

    For the second issue, this should work as it is. When the focus goes to the other control, the LeavingEdit event should be trigged, and your code executed.

    However, you can handle the Leave event on the GridControl, and in the handler, call the EndEdit method on the CurrentRow, so the cell leaves edition.


    void gridControl1_LostFocus( object sender, EventArgs e )
    ( ( CellRow )gridControl1.CurrentRow).EndEdit();

    Imported from legacy forums. Posted by André (had 3175 views)

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