Is this normal Listbox behavior?

  • Thread starter Thread starter KC
  • Start date Start date
K

KC

I'm filling a listbox in my code and I notice that when I run the program
the first item in the listbox is always selected. I haven't selected
anything though. When I have it run a quick unselect loop I still end up
with one item always selected.

If I unselect the first item, click on one further down the list and then
unselect that one, the first item is automatically selected again. Is this
normal? Do I have some property set that I shouldn't?
 
* "KC said:
I'm filling a listbox in my code and I notice that when I run the program
the first item in the listbox is always selected. I haven't selected
anything though. When I have it run a quick unselect loop I still end up
with one item always selected.

If I unselect the first item, click on one further down the list and then
unselect that one, the first item is automatically selected again. Is this
normal? Do I have some property set that I shouldn't?

I am not able to repro that behavior on Windows XP Professional + .NET
1.1. Do you use databinding with the control?
 
I'm not completely sure what you mean by databinding with the control. I put
the contents of an array (which is the listbox collection) into an arraylist
and set the listbox datasource equal to that arraylist, so I think the
answer is yes. I'm running Win2k by the way.

It's very peculiar.

Ken
 
* "KC said:
I'm not completely sure what you mean by databinding with the control. I put
the contents of an array (which is the listbox collection) into an arraylist
and set the listbox datasource equal to that arraylist, so I think the
answer is yes. I'm running Win2k by the way.

I am able to repro that when setting a datasource. You can unselect the
item by setting the listbox's 'SelectedIndex' property to -1 after assigning
the datasource.
 
KC said:
I'm filling a listbox in my code and I notice that when I run the program
the first item in the listbox is always selected. I haven't selected
anything though. When I have it run a quick unselect loop I still end up
with one item always selected.

If I unselect the first item, click on one further down the list and then
unselect that one, the first item is automatically selected again. Is this
normal? Do I have some property set that I shouldn't?

I have no idea - I don't remember my code ever doing this. You can
look through your listbox properties - anything in BOLD is in fact
different from the default - that may help.

John Fiala
jcfiala523-at-hotmail.com
http://www.livejournal.com/users/fiala_tech/
 
You are replying to an enquiry that was posted 5 years ago. The OP is
unlikely to be still looking out for a response. Please check the original
posting date before responding.
 
Back
Top