I have a listbox that has a context menu that goes with it. The context menu has 3 options on it following the basic "Create new...", "Edit selected..." and "Remove selected..." style.

The rule is that at least one item must be in the listbox at all times, the user can always create new items or edit existing ones, but if there is only one item in the listbox and the context menu opens, should I leave the "Remove selected..." item enabled and just show a messagebox when the user clicks it saying "You can't do this, you have to have at least one item in the list..." or, should I disable the "Remove selected..." item.

The UX Guidebook says to remove (as in hide or completely remove) any interface items, including menu items and tabs in tab views, where the item or items in the tab do not apply in the current context. HOWEVER, if the user expects the item to apply, you should leave the item, disable it, and explain why it is disabled. The example image they show is of a tab view with all the controls disabled and a info box at the bottom saying it doesn't apply.

Since I can't really add a little explanation to the menu item, should I go with a messagebox or should I disable the item? I don't like the idea of removing it in this case.

I'm sure it depends on the scenario, but any general suggestions would be wonderful!

I'd just disable it (removing is a bad idea in my opinion, as the user might be looking for that option and believe they are in the wrong place and go hunting for it, wasting their time and making them dislike your software). Most users realize that a disabled option means that there is something they need to do to enable it. That's where documentation comes in :)

^-- What Momerath said.

A message box would be a poor choice here as well. Why let someone select the menu item and then tell them "you can't do that," when you could simply disable it? As a general rule, I prefer to stop unavailable/disallowed actions as far upstream as I can--before they even happen, if possible.

Since I can't really add a little explanation to the menu item

Can't you? MenuItem has a ToolTip property.

agreed...

My preference would be to disable it and use the tooltip to explain why. Removing items can cause general confusion as the interface layout dynamically changes - generally try to keep things as consistent as possible. In my experience message boxes have a tendency to become annoying especially if the user forgets they can't do a thing.

This article has been dead for over six months. Start a new discussion instead.