This is a migrated thread and some comments may be shown as answers.

CommandBarTextBox Events

3 Answers 111 Views
CommandBar
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 29 Nov 2010, 05:18 PM
Good Day/Evening,

I've been using the new CommandBar which looks awesome I think but I have a problem with the CommandBarTextbox, I've put the CommandBarTextbox in the CommandBar and added the following code below but the events do not get hit at all. Any help would be much appreciated.

Public Sub New()
 
    ' This call is required by the designer.
    InitializeComponent()
 
    ' Add any initialization after the InitializeComponent() call.
    AddHandler txtMyCommandTextBox.KeyDown, AddressOf txtMyCommandTextBox_KeyDown
    AddHandler txtMyCommandTextBox.KeyPress, AddressOf txtMyCommandTextBox_KeyPress
    AddHandler txtMyCommandTextBox.KeyUp, AddressOf txtMyCommandTextBox_KeyUp
 
End Sub
 
Private Sub txtMyCommandTextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
    RadMessageBox.Show(e.KeyCode)
End Sub
 
Private Sub txtMyCommandTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
    RadMessageBox.Show(e.KeyChar)
End Sub
 
Private Sub txtMyCommandTextBox_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs)
    RadMessageBox.Show(e.KeyCode)
End Sub

3 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 29 Nov 2010, 06:17 PM
Hello Ryan,

I've recently reported this as an issue. You need to handle the events on the TextBoxItem instead. Have a look at the code below

Imports Telerik.WinControls.UI
Imports Telerik.WinControls
  
Public Class Form1
  
    Private WithEvents m_TextBoxItem As RadTextBoxItem
  
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.CommandBarTextBox1.Text = ""
        Me.CommandBarTextBox1.TextBoxElement.TextBoxItem.MaxLength = 3
        m_TextBoxItem = Me.CommandBarTextBox1.TextBoxElement.TextBoxItem
  
    End Sub
  
    ''' <summary>
    ''' This fires correctly
    ''' </summary>
    Private Sub CommandBarTextBox1TextBoxItem_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_TextBoxItem.TextChanged
        MessageBox.Show("m_TextBoxItem " & Me.CommandBarTextBox1.Text)
    End Sub
  
    ''' <summary>
    ''' This fires correctly
    ''' </summary>
    Private Sub CommandBarTextBox1TextBoxItem_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles m_TextBoxItem.KeyDown
        MessageBox.Show("m_TextBoxItem " & e.KeyValue.ToString())
    End Sub
  
    ''' <summary>
    ''' This only fires on initial load
    ''' </summary>
    Private Sub CommandBarTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CommandBarTextBox1.TextChanged
        MessageBox.Show("CommandBarTextBox1 " & Me.CommandBarTextBox1.Text)
    End Sub
  
    ''' <summary>
    ''' This doesn't fire
    ''' </summary>
    Private Sub CommandBarTextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles CommandBarTextBox1.KeyDown
        MessageBox.Show("CommandBarTextBox1 " & e.KeyValue.ToString())
    End Sub
End Class

hope this helps but let me know if you have any questions
Richard
0
Ryan
Top achievements
Rank 1
answered on 29 Nov 2010, 07:16 PM
Thanks for the solution, works perfectly.
0
Richard Slade
Top achievements
Rank 2
answered on 29 Nov 2010, 07:29 PM
Glad to have been able to help
Richard
Tags
CommandBar
Asked by
Ryan
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Ryan
Top achievements
Rank 1
Share this question
or