Results 1 to 3 of 3

Thread: Context Menu Question

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2005
    Posts
    48

    Context Menu Question

    Hey,

    Is there a way to capture which control the user executed a context menu from? In order words, if textboxes txtName and txtAddress have the same context menu, is there a way determine which one was clicked in the menuitem click event? The sender parameter is a reference to the actual menuitem and not the control...

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: Context Menu Question

    As a quick thought , how about using flags in both textboxes !

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Context Menu Question

    Here's what you do. You want to do something with or to a ContextMenu and/or a MenuItem. You go to the help/MSDN library and you read the help topic for each class to see if it tells you there. If not, then you follow the link to the member listing for the class(es) and you read the descriptions of each member to see if something there seems useful. Following this methodology you find exactly what you need in the SourceControl property of the ContextMenu.
    Gets the control that is displaying the shortcut menu.
    You can then follow the link for more information on that specific member, which will often incude a code sample. That is the first thing you should do EVERY time you don't know how to do something with or to a specific class. If you don't find what you're looking for you'll probably still learn something from the experience and you can still ask the question on a forum. That's how I've learned about 90 % of what I know about .NET development.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width