Home Forums WinForms controls Xceed Grid for WinForms Getting character number of winTextBox from QueryInputKey event Reply To: Getting character number of winTextBox from QueryInputKey event

User (Old forums)
Member
Post count: 23064

We suggest you use the TextChanged event on the TextBoxArea instead, and get the text length in the event handler.

e.g.:

//at Form_Load

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    AddHandler GridControl1.Columns( 0 ).CellEditorManager.ActivatingControl, AddressOf CellEditorManager_ActivatingControl
    AddHandler GridControl1.Columns( 0 ).CellEditorManager.DeactivatingControl, AddressOf CellEditorManager_DeactivatingControl

  End Sub

//Event handlers :

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

    Dim editor as Xceed.Editors.WinTextBox = CType( e.Control, Xceed.Editors.WinTextBox)
    AddHandler editor.TextBoxArea.TextChanged, AddressOf editor_TextChanged

  End Sub

  Private Sub CellEditorManager_DeactivatingControl( ByVal sender As Object, ByVal e As Xceed.Grid.Editors.CellEditorEventArgs )
   
    Dim editor as Xceed.Editors.WinTextBox = CType( e.Control, Xceed.Editors.WinTextBox)
    ‘this needs to be done, if not, subscriptions will pill up every time the editor is activated
    RemoveHandler editor.TextBoxArea.TextChanged, AddressOf editor_TextChanged
 
  End Sub

  Private sub editor_TextChanged(ByVal sender As System.Object, ByVal e As EventArgs )

    Dim value as String = CType( sender, TextBoxArea ).TextLength.ToString
    
  End Sub

 

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