I have a ContextMenuStrip attached to a list view, and it’s working great, but what I’m interested in knowing is how I can have it show up only when one or more items are selected in the listview.
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could use the
Openingevent. The event args has a Cancel property so that you can examine the state of your application and decide whether to have the menu show (by doing nothing) or prevent it from showing (by settinge.Cancel = true). However, like @Grzenio mentions, I would find it more intuitive if the item that i right-clicked on became selected automatically.Another option would be to use the
Openingevent to populate the context menu with only one disabled item, with a text like(no item is selected)or so; this would inform the user about why the command is not available.