I have a ContextMenuStrip containing two TextBoxes.
I want the validate the text inserted in a TextBox by using the TextBox.Leave event, but whenever I click outside the TextBox or the ContextMenuStrip, the event does not fire. The same for other events, like Validate, Enter etc. However, some events like MouseEnter or Click work.
Do you have any ideas?
Thank you!
I found a workaround using the LostFocus event on this post:
Just create LostFocus
event handler manually. NOTE- LostFocus
event is not showing in VS designer.
public Form1()
{
InitializeComponent();
toolStripTextBox1.LostFocus += ToolStripTextBox1_LostFocus;
}
private void ToolStripTextBox1_LostFocus(object sender, EventArgs e)
{
//Your code!!!
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.