Category / Section
How to get the textbox of the TextBoxBarItem and fire its events in WinForms XPToolBar?
1 min read
Textbox of TextBoxBarItem
You need to get hold of the internal TextBox in the TextBoxBarItem and you can access the textbox events associated with it. You can do this using the TextBoxItemBound event of the TextBoxBarItem, where you can get the internal textbox from args.TextBox. Please ensure to use the MainFrameBarManager to get this working. Please refer to the following code snippet.
C#
this.textBoxBarItem1.TextBoxItemBound += new Syncfusion.Windows.Forms.Tools.XPMenus.TextBoxItemBoundEventHandler(textBoxBarItem1_TextBoxItemBound); void textBoxBarItem1_TextBoxItemBound(object sender, Syncfusion.Windows.Forms.Tools.XPMenus.TextBoxItemBoundEventArgs args) { TextBox m_textbox = args.TextBox as TextBox; m_textbox.Validated += new EventHandler(m_textbox_Validated); } void m_textbox_Validated(object sender, EventArgs e) { Console.WriteLine("Event Fired"); }
VB
Private Sub textBoxBarItem1_TextBoxItemBound(ByVal sender As Object, ByVal args As Syncfusion.Windows.Forms.Tools.XPMenus.TextBoxItemBoundEventArgs) Handles textBoxBarItem1.TextBoxItemBoundAddHandler args.TextBox.Validated, AddressOf TextBox_Validated AddHandler args.TextBox.LostFocus, AddressOf TextBox_LostFocus End Sub Private Sub TextBox_Validated(ByVal sender As Object, ByVal e As EventArgs) Console.WriteLine("Validated event fired") End Sub
Reference link: https://help.syncfusion.com/windowsforms/xptoolbar/baritem-types#textboxbaritem