473,498 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bug with multiselect ListBox?

This works well on a single selection listbox:

protected override OnMouseDown(...)
{
base.OnMouseDown(...);
MessageBox.Show(this.SelectedIndex.ToString());
}

But on a multiple selection listbox you get a IndexOutOfRange exception.
Which is not documented as a possible exception being thrown by accessing
any of the ListBox properties. Apparently in the OnMouseDown event on a
multiple selection listbox something is in the wrong state and all the
selection properties (SelectedItems, SelectedIndices, SelectedIndex) cannot
be accessed.

Bug or feature?

/Gianluca
Nov 17 '05 #1
1 2454
What I would do is instead of using the general OnMouseDown event i would use
the onSelect event. Just a suggestion

"Gianluca" wrote:
This works well on a single selection listbox:

protected override OnMouseDown(...)
{
base.OnMouseDown(...);
MessageBox.Show(this.SelectedIndex.ToString());
}

But on a multiple selection listbox you get a IndexOutOfRange exception.
Which is not documented as a possible exception being thrown by accessing
any of the ListBox properties. Apparently in the OnMouseDown event on a
multiple selection listbox something is in the wrong state and all the
selection properties (SelectedItems, SelectedIndices, SelectedIndex) cannot
be accessed.

Bug or feature?

/Gianluca

Nov 17 '05 #2

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

Similar topics

2
6350
by: Sally | last post by:
I have a simple multiselect listbox with a rowsorce of MemberID, MemberName, SendLetter. SendLetter is a Yes/No field. What is the code to set SendLetter to Yes when the user selects MemberName? I...
2
3333
by: Cassie Pennington | last post by:
I am trying to write various items from a multiselect list box to an SQL statement to update a report, without success. SQL only appears to accept hard-coded data or control values from a form, not...
2
6056
by: Alan Lane | last post by:
Hello world: I'm using Access 2003. I have 2 listboxes. One is a single column. The other has two columns. I can use Dev Ashish's code (thanks Dev!) from the Access MVP Website to accumulate...
3
3610
by: kaosyeti via AccessMonster.com | last post by:
hey... i have an unbound multiselect listbox on a form that i want to use to populate text boxes on that form. so if a user selects the 3rd item in a list of 20, how can i have that item show up...
1
1829
by: asharma0001 | last post by:
Hi all, I was wondering whether somebody might be able to help me with a question I have on a MS Access Database I'm building. I have created a search form with a few multiselect listboxes....
0
7197
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
7375
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
5456
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,...
1
4899
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...
0
4584
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...
0
3088
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...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
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...

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.