Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / How to Call Validating Event in Button Click Event

How to Call Validating Event in Button Click Event

New Discussion
ferdin
ferdin asked on Oct 19, 2009 7:05 AM

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

 

Sign In to post a reply

Replies

  • 0
    Brian Fallon
    Brian Fallon answered on Nov 17, 2008 2:33 PM

    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.

    • 0
      ferdin
      ferdin answered on Nov 18, 2008 3:34 AM

      Thanks Brain Fallon,

      I dont understand it clearly. Could you more specific with this or could you please code that for me.

  • 0
    Rhea
    Rhea answered on Oct 19, 2009 7:05 AM

    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[quote user="ferdin"]

    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

    [/quote]….

     

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
ferdin
Favorites
0
Replies
3
Created On
Oct 19, 2009
Last Post
16 years, 4 months ago

Suggested Discussions

Tags

Created by

Created on

Oct 19, 2009 7:05 AM

Last activity on

Feb 23, 2026 4:54 PM