Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set a click event for a form?

Tags:

People also ask

Is it possible to trigger a click event from another form?

You can use internal as your modifier, so you can easily access the click event. for example you have a click event in form1. instead of making it private, public or protected. put it as internal this way you can easily access the method in other classes.

How do you call a button click event?

How can I call SubGraphButton_Click(object sender, RoutedEventArgs args) from another method? private void SubGraphButton_Click(object sender, RoutedEventArgs args) { } private void ChildNode_Click(object sender, RoutedEventArgs args) { // call SubGraphButton-Click(). }

How do you call a button click event in code behind?

To simulate the button click in code, you simply call the event handler: Button1_Click(object sender, EventArgs e). protected void Page_Load(object sender, EventArgs e) { //This simulates the button click from within your code. Button1_Click(Button1, EventArgs.


I have a c# form (let's call it MainForm) with a number of custom controls on it. I'd like to have the MainForm.OnClick() method fire anytime someone clicks on the form regardless of whether the click happened on the form or if the click was on one of the custom controls. I'm looking for behavior similar to the KeyPreview feature of forms except for mouse clicks rather than key presses.