PC Review


Reply
Thread Tools Rate Thread

Databinding a combo box

 
 
Jeff Mason
Guest
Posts: n/a
 
      9th Apr 2004
I'm observing some strange behavior when I use a bound combo box in conjunction with
the combo's anchor property. I define a form which contains just a textbox and a
combo box. The text box is placed before the combo in taborder, and is there only so
the focus will go someplace other than the combo box when the form is displayed.

In the form load event, I have the following code to create an arraylist and bind the
combo to it:

Dim a As ArrayList = New ArrayList

For i As Integer = 1 To 20
a.Add("Test Line " & i)
Next

ComboBox1.DataSource = a

When the form is displayed, the first item in the combo box's list is displayed in
the combo's associated textbox. If you set the combo's anchor property to any other
value than "Top, Left", the combo's text is displayed and also selected, even though
the combo does not have the focus.

If I load the combo "by hand", manually adding the above strings to the combo's Items
collection, no item is selected when the form is displayed, regardless of the anchor
property.

Anybody have any idea why the combo would choose to select text with any anchor value
other than "top, left" but not select it if it is "top, left"? Ad what does the
anchor property have to do with this, anyway?

I realize I can set the combo's SelectedIndex value to -1 after setting the
datasource, but I believe the behavior I am observing is inconsistent. Is this a bug
or is there something I don't understand?
 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      10th Apr 2004
Hi Jeff,

Most of us stopped looking at strange behaviour in the initialization fase
of the combobox.

However preventing the selectedindexchange to start, with a bool/switch/flag
which you set to true at the end of your load, will mostly overcome most
problems (not all).

I hope it helps anyway?

Cor


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Which databinding should i use for a combo box Claire Microsoft C# .NET 0 30th Jan 2008 02:51 PM
RE: combo box databinding =?Utf-8?B?ZWxiaXJybw==?= Microsoft ADO .NET 0 24th Sep 2004 07:33 PM
Re: combo box databinding Tal Sharfi Microsoft Dot NET 0 21st Sep 2004 11:24 PM
combo box databinding =?Utf-8?B?RWR3YXJk?= Microsoft ADO .NET 0 21st Sep 2004 02:29 PM
combo box databinding =?Utf-8?B?RWR3YXJk?= Microsoft Dot NET 0 21st Sep 2004 02:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:06 PM.