472,958 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 2206
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.