Link to home
Start Free TrialLog in
Avatar of sydneyguy
sydneyguyFlag for Australia

asked on

C# private void btnConnect_Click(object sender, EventArgs e) calling a button generated function

I have a function that is run off a button on the form but wish to call it from another normal function were i do not have the mouse pos set up for the event e

private void btnConnect_Click(object sender, EventArgs e)

i can use
btnConnect_Click("contact", EventArgs e)
its looking for {X = 33 Y = 10 Button = Left}  System.EventArgs  System.Windows.Forms.MouseEventArgs}

but not sure how to recreate the EventArgs e varable that the function wants

Argument '2': cannot convert from 'string' to 'System.EventArgs'
ASKER CERTIFIED SOLUTION
Avatar of effes
effes
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Ravi Vaddadi
Ravi Vaddadi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You could create EventArgs like any other object
new EventArgs();

new MouseEventArgs() { Button=MouseButtons.Left,Location = new Point(33,10)}
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sydneyguy

ASKER

the below code throws up the below errors

private void deleteemail_Click(object sender, EventArgs e)
        {
            new EventArgs();

            new MouseEventArgs() { Button=MouseButtons.Left,Location = new Point(33,10)}
        }

throws up  User generated image
I oftern run into this prop and woudl really like to get the artificial call going so that i do not have to re write code when an artificial call will do the perfect job
I suggested on how you could create EventArgs and MouseEventArgs. You cannot use the lines as is.

I agree with Idle_mind that you are better off using PerformClick() method of the button.

thanks every one looking at your response i have used a variation on all three inputs, so awarded the points as such thanks for your help