473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Right click to selct item in a Listbox

Is there a way to select an item ina listbox with the right click event?
basically I want a user to be able to rightclick an item which will select
the item and then bring up the context menu which has a delete option in it.

As it stands if I select an item and then rightclick a seperate item
selecting delete will remove the selected item instead of the one that was
right clicked

Cheers
Niels
Nov 21 '05 #1
2 1658
Hi,
One way is to handle the MouseDown event of the list box:

If (e.Button = MouseButtons.Right) Then
ListBox.SelectedIndex = ListBox.IndexFromPoint (e.X, e.Y)
End If

HTH

"Niels Jensen" <Ni*********@discussions.microsoft.com> wrote in message
news:34**********************************@microsof t.com...
Is there a way to select an item ina listbox with the right click event?
basically I want a user to be able to rightclick an item which will select
the item and then bring up the context menu which has a delete option in it.

As it stands if I select an item and then rightclick a seperate item
selecting delete will remove the selected item instead of the one that was
right clicked

Cheers
Niels
Nov 21 '05 #2
Worked like a charm!
Thanks Shiva

Niels

"Shiva" wrote:
Hi,
One way is to handle the MouseDown event of the list box:

If (e.Button = MouseButtons.Right) Then
ListBox.SelectedIndex = ListBox.IndexFromPoint (e.X, e.Y)
End If

HTH

"Niels Jensen" <Ni*********@discussions.microsoft.com> wrote in message
news:34**********************************@microsof t.com...
Is there a way to select an item ina listbox with the right click event?
basically I want a user to be able to rightclick an item which will select
the item and then bring up the context menu which has a delete option in it.

As it stands if I select an item and then rightclick a seperate item
selecting delete will remove the selected item instead of the one that was
right clicked

Cheers
Niels

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Chris | last post by:
I'm able to add a context menu to the right click on a listbox but it does not select the item in the listbox. I would like the context menu before it pops up to select the item that the mouse was...
6
by: Dan Bass | last post by:
If you look at explorer, right clicking on a file, first selects the file, then throws up the context menu relating to that selection. With a Windows ListBox control and a simple context menu,...
6
by: Steve | last post by:
Hi, I open up a webform (vb.net) and populate a listbox control on the Page load event. If I click on (select) and item from the listbox I want to write the value of the selected item to a...
9
by: Larry Serflaten | last post by:
I'm drawing my own inherited listbox, and I don't want the user to select any items, but I do want to allow them to scroll the listbox. When they click on an item, there is a flicker of the...
1
by: BillyB | last post by:
I have a context menu tied to a list box. When I right-click on an item, I'd like that item to be selected before the context menu invokes, similar to how Outlook Express works when right-clicking...
3
by: Art | last post by:
Hi, I've got a bunch of ListBoxes. I want to have a context menu that will include, for example, an edit routine. The problem I have is the following. Suppose you select item 1. Then you move...
2
by: Hardik Shah | last post by:
Hi, I want to create menu , when my user right click from combo box's list item. I use Contextmenu property of combobox and assign menu for it, but it only effected when combobox's list item not...
1
by: akameswaran | last post by:
I have a list box, I'd like to generate a right click menu for items in the list box. The problem is unless I left click the item first, I can't figure out which item in the list I clicked over. ...
2
by: erbear | last post by:
Hi all, I am new to VB, and I am having some troubles. I have a listbox that when you click on the item it displays a picture in a picture box and a message in a label. It works fine when an item...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.