Hi Everyone
How to fire a Ultratextbox validating event in Ultrabutton Click event. I tried it usually like these following two methods both throws same errors like this
Method 1:
{
uiTextBox_Validating(this, CancelEventArgs.Empty);
}
Method 2:
uiTextBox_Validating(this, e);
It throws some errors like
Error 2 The best overloaded method match for 'Task_2_Control_Panel.FrmControlPanel.uiTextbox_Validating(object, System.ComponentModel.CancelEventArgs)' has some invalid arguments D:\Task 2 Control Panel\Control Panel.cs 1225 13 Task 2 Control Panel
Error 3 Argument '2': cannot convert from 'System.EventArgs' to 'System.ComponentModel.CancelEventArgs' D:\Task 2 Control Panel\Control Panel.cs 1225 44 Task 2 Control Panel
Could anyone help me to sort this issue.
Thanks in advance
Ferdin
I too had the same problem when I tried to fire a validating event within a ButtonClick event.I went through the reply answer to ur post.But answer is not clear to me as well
ferdin said: Hi Everyone How to fire a Ultratextbox validating event in Ultrabutton Click event. I tried it usually like these following two methods both throws same errors like this Method 1: private void uiButton1_Click(object sender, EventArgs e) { uiTextBox_Validating(this, CancelEventArgs.Empty); } Method 2: private void uiButton1_Click(object sender, EventArgs e) { uiTextBox_Validating(this, e); } It throws some errors like Error 2 The best overloaded method match for 'Task_2_Control_Panel.FrmControlPanel.uiTextbox_Validating(object, System.ComponentModel.CancelEventArgs)' has some invalid arguments D:\Task 2 Control Panel\Control Panel.cs 1225 13 Task 2 Control Panel Error 3 Argument '2': cannot convert from 'System.EventArgs' to 'System.ComponentModel.CancelEventArgs' D:\Task 2 Control Panel\Control Panel.cs 1225 44 Task 2 Control Panel Could anyone help me to sort this issue. Thanks in advance Ferdin
private void uiButton1_Click(object sender, EventArgs e)
Thanks Brain Fallon,
I dont understand it clearly. Could you more specific with this or could you please code that for me.
The Form class exposes a method, 'ValidateChildren', which triggers the Validating event for each child of the form. If you want to call the event handler directly, you should not use CancelEventArgs.Empty, but rather a new instance of CancelEventArgs, because the static Empty property is inherited from the System.EventArgs class, and you need a strongly-typed CancelEventArgs instance to call the event handler directly. Also, the value of the 'sender' parameter should probably be uiTextBox, not this, in case the handler logic is expecting the sender to be of a specific type.