Need some help with menus

gate13

New member
Joined
Jan 29, 2005
Messages
1
Programming Experience
Beginner
Hello everybody,

I am not only new to VB.NET but to programming as well(startted about two weeks ago). I am having a problem that I can't seem to figure out.

I have a form with a menu item automobile. The menu items listed below this one are add and delete (when you click on automobile these appear).

I have three comboboxes in the middle of the form, called ComboxAutomobileType, ComboPrice and ComboQuantity.

The three comboboxes are linked meaning that regardless of where I make a selection, the other two will also display the corresponding information to the selection I made.

What I want is to set the delete menu item 's (MnuDelete) enabled property to false if nothin has been selected.

The following is what I tried:

Private Sub MnuAutomobile_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MnuAutomobile.Click

If (ComboAutomobileType.SelectedIndex > -1) Then
MnuDelete.Enabled = True
End If

End Sub


and then I tried the following:

Private Sub MnuAutomobile_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MnuAutomobile.Click

If (ComboAutomobileType.SelectedItem Is Nothing) Then
MnuDelete.Enabled = False
Else
MnuDelete.Enabled = True
End If

end sub

but nothing worked. Any help would be greatly appreciated.
 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
You could set MnuDelete's Enabled property to false in the designer, then enable it in comboAutomobileType's SelectedIndexChanged event handler. If the comboBox is filled with only valid entries (meaning there isn't one that says something like 'Select Automobile Type' or something) then there is no reason to disable the menuItem. But if there is such an item, you could check to see if that item is selected and then disable the delete menuItem.

Hope that helps and happy programming.
 
Top Bottom