Display a PopUp Menu when a ListBox Item is Right-Clicked

Category:
Forms and Controls
Type:
Snippets
Difficulty:
Intermediate
Author:
Intelligent Solutions Inc.

Version Compatibility: Visual Basic 6, Visual Basic 5

More information:
This is an example of how to display a pop-up menu when a list box item is right clicked. Refer to the comments for instructions regarding how to implement it in your own projects.

Thanks to Adam Hewgill for correcting a bug in this program that prevented it from working with list boxes that contained scroll bars. The bug fix was posted 08/10/01.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: