I have a windows forms application. When I click on a window this activates the form and then I need to click again to call the particular control click event. For example if I click on a button this activates the form and then I need to click the button again.
Is there a way to perform the control click and window activation in one click? Preferably I would want this to work with whatever the clickable control is (menu,button, label etc)
Yes, there are such ways, but you never should do it for "regular" UI development. This is a total abuse which makes your code unreliable and bad for support. This is only the indication that you have no idea how to develop UI legitimately, nothing else.—SA
All you need is to learn some UI development.
In your particular case, you have more then enough, without click simulation: you have the event
System.Windows.Forms.Control.Click of a button, and the event
System.Windows.Form.Activated, or, alternatively, as you are writing you form class anyway, you can simply override the virtual form method
In your question, you never explain why would you like to do some action on activation, and why such action should be the same as on the button click. I doubt you really need exactly that, but here, you also already have everything you need. For this, you only need to be able to… write code, in particular, method (instead of just filling in those created by the designer).
Just create some form instance method doing what you need. Call this method from the button click event and from the activation event. Got the idea?
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)