Help!!!

A

Ash Phillips

Hi, in VB6, I could use PopupMenu() to display a menu on a control such as a
list view.

I have tried setting a Context Menu to a List View in VB.NET but I can't
seem to get
the same functionality that I had and need like in VB6.

Basically, I just want to disable menu items in the context menu if there is
no item in the List View selected.

Also, on the subject, in VB6 there was lvwListView.ListItems.SelectedItem -
I see "SelectedItems" in VB.NET and it doesn't seem to work at all?

Like I need things to be disabled when nothing is selected and I need things
to work with only one item selected.

Thanks in advance :)

Ash
 
C

Chris Botha

SelectedItems.Count gives the number of items selected.
SelectedItems(0) gives the 1st selected item, etc.

Ash Phillips said:
Hi, in VB6, I could use PopupMenu() to display a menu on a control such as a
list view.

I have tried setting a Context Menu to a List View in VB.NET but I can't
seem to get
the same functionality that I had and need like in VB6.

Basically, I just want to disable menu items in the context menu if there is
no item in the List View selected.

Also, on the subject, in VB6 there was
lvwListView.ListItems.SelectedItem -
 
A

Ash Phillips

Thanks - I'll give that a try :)

Anyone know anything with regards to the ContextMenus?

Thanks again!
 
C

Chris Botha

You say "I just want to disable menu items in the context menu if there is
no item in the List View selected."

You must process the Popup event of the context menu. The code in the event
must be something like:

Dim oneMenuItem As MenuItem
For Each oneMenuItem In ContextMenu1.MenuItems
If ListView1.SelectedItems.Count = 0 Then
oneMenuItem.Enabled = False
Else
oneMenuItem.Enabled = True
End If
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top