By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,725 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,725 IT Pros & Developers. It's quick & easy.

ContextMenu.SourceControl on RichTextBox's

P: n/a
MD
I have a ContextMenu that is assigned to 3 RichTextBox's (i.e., if you
right-click on any of the 3 RichTextBox's, you get the same ContextMenu).
My ContextMenu has 2 items, each of which have their own click event
handlers. When I click on any of the options in the ContextMenu, I want to
know which RichTextBox the ContextMenu is currently opened in, so I thought
I could check the SourceControl property. The problem is, the property is
never assigned (it is null). If I assign the ContextMenu to another
control, such as a Button, the SourceControl property is properly assigned
when I right-click on the button. Why is that? To work around this
problem, I use the MouseEnter event to update a private variable that tells
me where the mouse is, so when the ContextMenu is opened, I look at that
variable. Seems like a hack - is there a better way?
Nov 15 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.