471,305 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,305 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 2151
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Chandra | last post: by
3 posts views Thread by TT (Tom Tempelaere) | last post: by
3 posts views Thread by Dominique Vandensteen | last post: by
30 posts views Thread by dbuchanan | last post: by
5 posts views Thread by Eric A. Johnson | last post: by
6 posts views Thread by kmercer46 | last post: by
reply views Thread by rosydwin | last post: by

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.