473,396 Members | 2,081 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.

ComboBox index needs to be set twice

Hello.
I have a combobox in a form (cmbNames).
The DataSource property is some arraylist of strings.
I have a button which is supposed to "clean" the combobox and deselect any
item.
Therefore, I do:
cmbNames.SelectedIndex = -1;

If index 0 was selected (meaning, the first item on the list) - the combobox
indeed goes to index -1 and there is no selected item.
if the selected item is not 0, meaning not the first item in the list - the
1st click on the button will select item 0 (the SelectedItem will be 0), and
another click will select nothing.

Why does that happen ?

(I attached a messagebox to the IndexChanged event of the combo, that pops
up the current index. When let's say index 3 is selected, on the click of
the button 2 messageboxes appear, the first saying -1, the second says 0. I
donno why is that!)

10x
Dec 24 '05 #1
5 2219
It's a bug.
http://support.microsoft.com/default...b;en-us;327244

--
Tim Wilson
..NET Compact Framework MVP

"Nadav" <na****@gmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello.
I have a combobox in a form (cmbNames).
The DataSource property is some arraylist of strings.
I have a button which is supposed to "clean" the combobox and deselect any
item.
Therefore, I do:
cmbNames.SelectedIndex = -1;

If index 0 was selected (meaning, the first item on the list) - the combobox indeed goes to index -1 and there is no selected item.
if the selected item is not 0, meaning not the first item in the list - the 1st click on the button will select item 0 (the SelectedItem will be 0), and another click will select nothing.

Why does that happen ?

(I attached a messagebox to the IndexChanged event of the combo, that pops
up the current index. When let's say index 3 is selected, on the click of
the button 2 messageboxes appear, the first saying -1, the second says 0. I donno why is that!)

10x

Dec 24 '05 #2
Nadav wrote:
Hello.
I have a combobox in a form (cmbNames).
The DataSource property is some arraylist of strings.
I have a button which is supposed to "clean" the combobox and deselect any
item.
Therefore, I do:
cmbNames.SelectedIndex = -1;

If index 0 was selected (meaning, the first item on the list) - the combobox
indeed goes to index -1 and there is no selected item.
if the selected item is not 0, meaning not the first item in the list - the
1st click on the button will select item 0 (the SelectedItem will be 0), and
another click will select nothing.

Why does that happen ?

(I attached a messagebox to the IndexChanged event of the combo, that pops
up the current index. When let's say index 3 is selected, on the click of
the button 2 messageboxes appear, the first saying -1, the second says 0. I
donno why is that!)


Install .NET 1.1 Service Pack
I had a similar problem in combination of combo box and a text box and
SP1 helped
Dec 24 '05 #3
Tim Wilson wrote:
It's a bug.
http://support.microsoft.com/default...b;en-us;327244


Wow, it's actually a bug for .NET 1.0 - why not install at least 1.1 SP1 ?
Dec 24 '05 #4
Thanks alot.
I understand that it's not solved at the moment (correct?)
I have Frameworks 1.1
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:Or**************@TK2MSFTNGP10.phx.gbl...
It's a bug.
http://support.microsoft.com/default...b;en-us;327244

--
Tim Wilson
.NET Compact Framework MVP

"Nadav" <na****@gmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello.
I have a combobox in a form (cmbNames).
The DataSource property is some arraylist of strings.
I have a button which is supposed to "clean" the combobox and deselect any item.
Therefore, I do:
cmbNames.SelectedIndex = -1;

If index 0 was selected (meaning, the first item on the list) - the combobox
indeed goes to index -1 and there is no selected item.
if the selected item is not 0, meaning not the first item in the list -

the
1st click on the button will select item 0 (the SelectedItem will be 0),

and
another click will select nothing.

Why does that happen ?

(I attached a messagebox to the IndexChanged event of the combo, that pops up the current index. When let's say index 3 is selected, on the click of the button 2 messageboxes appear, the first saying -1, the second says

0. I
donno why is that!)

10x


Dec 24 '05 #5
The knowledge base article indicates that this is a problem for 1.0 but it's
also a problem in 1.1. This has been fixed with 2.0.

--
Tim Wilson
..NET Compact Framework MVP

"Nadav" <na****@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Thanks alot.
I understand that it's not solved at the moment (correct?)
I have Frameworks 1.1
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:Or**************@TK2MSFTNGP10.phx.gbl...
It's a bug.
http://support.microsoft.com/default...b;en-us;327244

--
Tim Wilson
.NET Compact Framework MVP

"Nadav" <na****@gmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello.
I have a combobox in a form (cmbNames).
The DataSource property is some arraylist of strings.
I have a button which is supposed to "clean" the combobox and deselect any item.
Therefore, I do:
cmbNames.SelectedIndex = -1;

If index 0 was selected (meaning, the first item on the list) - the

combobox
indeed goes to index -1 and there is no selected item.
if the selected item is not 0, meaning not the first item in the
list -
the
1st click on the button will select item 0 (the SelectedItem will be
0), and
another click will select nothing.

Why does that happen ?

(I attached a messagebox to the IndexChanged event of the combo, that

pops up the current index. When let's say index 3 is selected, on the click of the button 2 messageboxes appear, the first saying -1, the second says

0.
I
donno why is that!)

10x



Dec 24 '05 #6

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

Similar topics

4
by: Chandra | last post by:
Hello Sir, This is Chandra and Working as Software Engineer. I got a really weird problem with ComboBoxes. I have set the ComboBox DroppedDown Property to true. Now the actual problem is...
3
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
3
by: Don | last post by:
My user control has a combobox with an arraylist attached to it along with custom add and remove methods. The "Add" method is working great. However I don't understand why the "Remove" method...
3
by: Dominique Vandensteen | last post by:
I posted this before but did some extra testing... combobox with 3 elements (DropDownList style) via code (button.click) I set the selectedIndex to -1 if element at index 0 is selected then...
7
by: sparkle | last post by:
Hi Everybody, I'm filling a combobox from a class, which works fine on it's own. But when I insert code to fill in other controls something in the combobox fill is causing the...
2
by: Steve F. | last post by:
I have a problem. I use a combobox in my datagrid, but I noticed, as soon as the user clicks on the field where the combobox, the event fires with a index value of 0, then of course with the...
30
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
5
by: Eric A. Johnson | last post by:
Hi Everyone, I am at my wit's end here. I have a combobox (combyQueryTitle) that I need to use in order to select a query for my database project. Therefore, I am using the...
6
by: kmercer46 | last post by:
just asking on how to add item data in combobox?? in vb6; combo1.additem "Item 1" combo1.ItemData(combo1.NewIndex) = 1 but how about in .net??
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.