Is this normal Listbox behavior?

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?
 
H

Herfried K. Wagner [MVP]

* "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?
 
K

KC

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
 
H

Herfried K. Wagner [MVP]

* "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.
 
J

John Fiala

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/
 
J

James Hahn

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top