Jump to content
  • Advertisement
Sign in to follow this  
cignox1

[.net] PerformClick on a Panel?

This topic is 3963 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I need to simulate a mouse click on a panel, but I don't know how to do that. I've read that I could use win32 SendMessage(), but for a couple of reasons (possible future use with mono being one of them) I would prefer a pure .Net alternative. Is there a way to raise a Click event on a control just like PerformClick() does on buttons? Thank you.

Share this post


Link to post
Share on other sites
Advertisement
Create a MouseEventArgs whose Button property is set to the System.Windows.Forms.MouseButtons.Left value.

Then call the OnMouseClick method with this MouseEventArgs as the argument on the Panel you are using.

That will do what you need.
theTroll

Share this post


Link to post
Share on other sites
Quote:
Original post by TheTroll
Create a MouseEventArgs whose Button property is set to the System.Windows.Forms.MouseButtons.Left value.

Then call the OnMouseClick method with this MouseEventArgs as the argument on the Panel you are using.

That will do what you need.
theTroll


Thank you but aren't these handlers protected? Anyway I was able to solve my problem: I would have preferred to generate the event, but the workaround I used should do the job.
Thank you again.

Share this post


Link to post
Share on other sites
Yes it is protected but you can create your own public method and put it in your own panel. Then just call the base class method.

theTroll

[Edited by - TheTroll on July 18, 2007 11:58:44 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!