Home Forums WinForms controls Xceed Grid for WinForms Updating rows in a group

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

    Hi,

    I want to know how to update the rows if any 1 row is changed. For eg lets say I have 2 columns -table & alias. Assume there are 4 rows in a group and when I edit alias column other 3 should automatically change. Any idea how to get this done.

    Imported from legacy forums. Posted by prem_rajani (had 4514 views)

    User (Old forums)
    Member
    Post count: 23064

    Try this (untested) code:<code>grid.DataRowTemplate.Cells[“alias”].LeavingEdit += new LeavingEditEventHandler(gridColumnAliasLeavingEdit);
    private void gridColumnAliasLeavingEdit(object sender, LeavingEditEventArgs e) {
    Cell cell = sender as Cell;
    int columnIndex = cell.ParentColumn.Index;
    CellRow row = cell.ParentRow;
    GroupBase group = row.ParentGroup;
    if (group != null)
    foreach(DataRow dataRow in group.GetSortedDataRows(true))
    if (dataRow != row)
    dataRow.Cells[columnIndex].Value = e.NewValue;
    }</code>

    Imported from legacy forums. Posted by Tommy (had 260 views)

    User (Old forums)
    Member
    Post count: 23064

    I’m sorry Im new so where do I add the code and please tell it VB not C#. I tried writing in datarowtemplate keydown event. When tab button is pressed then event leavingedit is called. But i dont see any leavingedit. I see just leavedit() which asks commit as parameter.

    Imported from legacy forums. Posted by prem_rajani (had 331 views)

    User (Old forums)
    Member
    Post count: 23064

    Just check out the coding and let me know where I went wrong.

    In form load event i added:

    Dim cell As DataCell
    For Each cell In GridControl1.DataRowTemplate.Cells
    AddHandler cell.LeavingEdit, AddressOf Me.cells_LeavingEdit
    Next cell

    Then the event is called

    Private Sub cells_LeavingEdit(ByVal sender As Object, ByVal e As LeavingEditEventArgs)
    Dim cell As Cell = CType(sender, Cell)
    Dim columnindex
    Dim datarow As DataRow
    columnindex = cell.ParentColumn.Index
    Dim row As CellRow = cell.ParentRow
    Dim group As GroupBase = row.ParentGroup
    If IsDBNull(group) = False Then
    For Each datarow In group.GetSortedDataRows(True)
    If datarow Is row Then
    datarow.Cells(columnindex).value = e.NewValue
    End If
    Next
    End If
    End Sub

    Imported from legacy forums. Posted by prem_rajani (had 352 views)

    User (Old forums)
    Member
    Post count: 23064

    Try this:<code>’ In form load event:
    AddHandler GridControl1.DataRowTemplate.Cells(“alias”).LeavingEdit, AddressOf Me.cell_Alias_LeavingEdit

    ‘ event handler:
    Private Sub cell_Alias_LeavingEdit(ByVal sender As Object, ByVal e As LeavingEditEventArgs)
    Dim cell As Cell = CType(sender, Cell)
    Dim row As CellRow = cell.ParentRow
    Dim dataRow As DataRow
    Dim group As GroupBase = row.ParentGroup
    If Not (group Is Nothing) Then
    For Each dataRow In group.GetSortedDataRows(True)
    If dataRow <> row Then
    dataRow.Cells(“alias”).Value = e.NewValue
    End If
    Next
    End If
    End Sub</code>

    Imported from legacy forums. Posted by Tommy (had 248 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Tommy thnks for your help. Its working now. As I keep exploring grid I’ll get more questions. You guyz are gr8

    Imported from legacy forums. Posted by prem_rajani (had 378 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi tommy,

    sorry to disturb u again. But I’m facing another problem now. In the leaving event after typing a word either I press enter or down arrow it works. But suppose I delete the rows and add them back, then enter key doesnt work. What I mean is after typing the word, I press enter key. The second column gets the value but current row clears. Whys is that? Can you please look into this or for time being how to trap enter key. If some1 presses enter key nothing should happen. Only by pressing down arrow it should update the group. Hope you are able to get me.

    Imported from legacy forums. Posted by prem_rajani (had 5545 views)

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