473,569 Members | 2,729 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selecting index in ComboBox with right mouse click

I would like to set the index in a ComboBox with the item under the
mouse when I right click the mouse. I have set up a context menu with
2 items, all that works great. I want to execute the instructions on
the item under the mouse but I can't get it to select with the right
mouse. Anyone know how I can select an item with the right mouse
button?

Help would be greatly appreciated,

Joe

Aug 7 '06 #1
1 6793
This should do the trick:

private void listBox1_MouseD own(object sender, MouseEventArgs e) {
Point p = new Point(e.X, e.Y);
if ( (e.Button & MouseButtons.Ri ght) == MouseButtons.Ri ght ) {
for ( int idx = 0; idx < listBox1.Items. Count; idx++ ) {
if ( listBox1.GetIte mRectangle(idx) .Contains(p) ) {
listBox1.Select edIndex = idx;
break;
}
}
}
}

John Opincar
jo**********@su ndesksoftware.c om

"Joe Blow" <bl*****@hotmai l.comwrote in message
news:11******** **************@ n13g2000cwa.goo glegroups.com.. .
>I would like to set the index in a ComboBox with the item under the
mouse when I right click the mouse. I have set up a context menu with
2 items, all that works great. I want to execute the instructions on
the item under the mouse but I can't get it to select with the right
mouse. Anyone know how I can select an item with the right mouse
button?

Help would be greatly appreciated,

Joe

Aug 8 '06 #2

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

Similar topics

1
4771
by: Oren Kaplan | last post by:
Hello, I posted a msg on the Access-related groups in hope someone there could help me but since almost two days have past and I didnt get a response (Im a bit hard pressed with the problem) I thought I might try some of you guys since you also deal with the Visual part of visual basic and since vba shouldn`t be all that different from vb.......
9
1830
by: Ant | last post by:
Hi, I'm new to .NET, though program with VB. I'm used to selecting an event from the right side drop down box of the VB IDE. That seems to have changed with ..NET. How do you choose an event, say for example, the click event of a form object so as to write a method for that event. Thanks for your help on this Regards Ant
3
2626
by: Pete | last post by:
I have a combobox which is used to select records, which is satisfactory at the moment. However, a second user is going to start using this database and there will be 1600 records. This makes the combobox a little unfeasable as searching through this many names would be difficult and time-consuming. I would like the user to be able to...
4
36342
by: Sue Bricker | last post by:
Greetings. In Access, is there a way to open up a drop-down combobox with keys on the keyboard, instead of using the mouse to click on the down arrow of the combobox? I really prefer to use the arrows on the keyboard and the enter key to make my selection. But if I have to click on the down arrow of the combobox then I might as well use the...
3
1041
by: JLW | last post by:
I've tried everyone's suggestion, and the only way it works is if I click out of the app windows, then back in. WTF is going on with that? JLW
2
1573
by: Peter Proost | last post by:
Hi group could someone please confirm this behavior? Place a combobox on a form an add some items to it, then in the combobox_keyup event place the following code: combobox1.droppeddown = true When I then run the programma and type something in the combobox, my mouse becomes invisible on the entire region of the form once you move the mouse...
0
1403
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 active. When my user on any combobox's item and he right click the mouse , menu doesn't appear. How to create menu. Thanks in advance.
2
4845
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 active. When my user on any combobox's item and he right click the mouse , menu doesn't appear. How to create menu. Thanks in advance.
12
5437
by: Gerhard | last post by:
This is bizarre... Im having problems with the combobox AfterUpdate event: Im running Access 2003. I created an unbound combobox with 3 columns on a form. The Row Source is from a table. Bound Column = 1 and LimitToList = No,,, thus the user can edit the data in the 1st-Column after they selected one of the rows in the combobox. ...
0
7694
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6278
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.