Home Forums WinForms controls Xceed Grid for WinForms Numeric Editor Keypress Event Help

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

    I have a grid with Numeric Editors in columns 2-5 and the idea is to move through the numeric cells on the “Enter” keypress event (which is also the key that closes the editor)

    I want to move like so 2a –> 3a –> 4a –> 5a –> 2b –> 3b –> 4b –> 5b –> 2c –> etc…

    I put the handlers in place that I THOUGHT would trap the keypress events, but they are not catching ANY keypress events, so I must have the wrong one.

    Here’s what I have; (BTW, does this message board program support CODE tags?)

    Private Sub NumericManager_ActivatingControl(ByVal sender As Object, ByVal e As Xceed.Grid.Editors.CellEditorEventArgs)

    … Dim t_Editor As Xceed.Editors.WinNumericTextBox = CType(e.Control, Xceed.Editors.WinNumericTextBox)

    … AddHandler t_Editor.KeyPress, AddressOf Editor_KeyPress
    End Sub

    Private Sub NumericManager_DeactivatingControl(ByVal sender As Object, ByVal e As Xceed.Grid.Editors.CellEditorEventArgs)

    … Dim t_Editor As Xceed.Editors.WinNumericTextBox = CType(e.Control, Xceed.Editors.WinNumericTextBox)

    … RemoveHandler t_Editor.KeyPress, AddressOf Editor_KeyPress
    End Sub

    Private Sub Editor_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
    … Stop
    End Sub

    –Now keep in mind, I DO have the Activating and Deactivating events firing, so anytime I press a key, shouldn’t the STOP statement fire?

    Imported from legacy forums. Posted by Rock (had 2427 views)

    User (Old forums)
    Member
    Post count: 23064

    Cleaned up the post, should be easier to read. “<code > — </code >” tags are supported if anyone else is wondering. (Remove the spaces though)

    <code>Private Sub NumericManager_ActivatingControl(ByVal sender As Object, ByVal e As Xceed.Grid.Editors.CellEditorEventArgs)
    Dim t_Editor As Xceed.Editors.WinNumericTextBox = CType(e.Control, Xceed.Editors.WinNumericTextBox)
    AddHandler t_Editor.KeyPress, AddressOf Editor_KeyPress
    End Sub

    Private Sub NumericManager_DeactivatingControl(ByVal sender As Object, ByVal e As Xceed.Grid.Editors.CellEditorEventArgs)
    Dim t_Editor As Xceed.Editors.WinNumericTextBox = CType(e.Control, Xceed.Editors.WinNumericTextBox)
    RemoveHandler t_Editor.KeyPress, AddressOf Editor_KeyPress
    End Sub

    Private Sub Editor_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
    Stop
    End Sub </code>Any ideas about what I’m missing?

    Imported from legacy forums. Posted by Rock (had 390 views)

    User (Old forums)
    Member
    Post count: 23064

    The problem is that the KeyPress is not triggered for the “Enter” key because it is not an input key.

    So what you can do is handle the QueryInputKey event of the NumericEditor, and “tell” the grid that the “Enter” is an input key for the editor. This will result in the KeyPress being raised, and you will be able to do what you want.

    e.g.:

    <code>
    numEd.QueryInputKey += new QueryEditorInputKeyEventHandler( numEd_QueryInputKey );

    void numEd_QueryInputKey( object sender, QueryEditorInputKeyEventArgs e )
    {
    if( e.KeyData == Keys.Enter )
    {
    e.IsInputKey = true;
    }
    }
    </code>

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

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