Home Forums WinForms controls Xceed Grid for WinForms cannot raise keydown events in DataGrid

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

    I hav a datagrid on a Windows Desktop application and the grid will hav an empty row at the bottom. When the user keys in the first character in any of the columns in the last row I need to add an additional row to the grid.

    The datagrid has unbound columns and I am populating the rows into the datagrid from the code behind.

    I am tryin to use the Keydown event for each of the column in the grid as follows (I hav 3 columns in the datagrid.)

    Private Sub celldataRowTemplate1Column1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles celldataRowTemplate1Column1.KeyDown

    If Me.GridControl1.DataRows.IndexOf(Me.GridControl1.CurrentRow) = Me.GridControl1.DataRows.Count – 1 Then

    MsgBox(“Last row key down”)

    End If

    End Sub

    Private Sub celldataRowTemplate1Column1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles celldataRowTemplate1Column2.KeyDown

    If Me.GridControl1.DataRows.IndexOf(Me.GridControl1.CurrentRow) = Me.GridControl1.DataRows.Count – 1 Then

    MsgBox(“Last row key down”)

    End If

    End Sub

    Private Sub celldataRowTemplate1Column1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles celldataRowTemplate1Column3.KeyDown

    If Me.GridControl1.DataRows.IndexOf(Me.GridControl1.CurrentRow) = Me.GridControl1.DataRows.Count – 1 Then

    MsgBox(“Last row key down”)

    End If

    End Sub

    The event is not being raised. Any suggestions ???

    regards

    Kishore

    Imported from legacy forums. Posted by kvanapal (had 2072 views)

    User (Old forums)
    Member
    Post count: 23064

    You need to subscribe to the cell editor, and not the column. Use the ActivatingControl event to accomplish this :

    In form load before loading the data :

    gridControl1.Columns[ 1 ].CellEditorManager.ActivatingControl += new CellEditorEventHandler(CellEditorManager_ActivatingControl);

    gridControl1.Columns[ 1 ].CellEditorManager.DeactivatingControl += new CellEditorEventHandler(CellEditorManager_DeactivatingControl);

    Events :

    private void CellEditorManager_ActivatingControl(object sender, CellEditorEventArgs e)
    {
    ( ( Xceed.Editors.WinTextBox )e.Control).TextBoxArea.KeyUp += new KeyEventHandler(TextBoxArea_KeyUp);
    }

    private void CellEditorManager_DeactivatingControl(object sender, CellEditorEventArgs e)
    {
    ( ( Xceed.Editors.WinTextBox )e.Control).TextBoxArea.KeyUp -= new KeyEventHandler(TextBoxArea_KeyUp);
    }

    private void TextBoxArea_KeyUp(object sender, KeyEventArgs e)
    {
    System.Diagnostics.Debug.WriteLine( “in editor KeyUp” );
    }

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

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