473,394 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Databinding a combo box

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?
Nov 20 '05 #1
2 2132
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
Nov 20 '05 #2
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
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: CGuy | last post by:
URGENT HELP REQUIRED FROM GURUS Hi, I have a custom object that implements ICollection and IListSource. This object has also an enumerator defined for it which implements IEnumerator and...
2
by: Cecilio | last post by:
Hi. I want to know hi i can show a combo without any text value, after y make a databinding with it. Thanks
1
by: ZZZ | last post by:
I have several combo's with databinding values. when a user starts typen, it's autocompleting so far so good but i don't want the user to have the ability to type a values that's not in the...
3
by: Lloyd Sheen | last post by:
I have several apps that use a roll your own approach, but I am embarking on a project which will not allow that with the time constraints. I have gened up a little app to try the databinding...
0
by: Jeff Mason | last post by:
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...
1
by: Gary Shell | last post by:
I have a pair of combo boxes on a form. Both have their SelectedValue property bound to a column on a table called "Input_Output". One column is called "Class" and the second is called "SubClass"....
0
by: Michael | last post by:
Hi everyone, I'm working on cutting down code in a form I'm working on, and decided to bind the controls to a dataset. I have two problems now. I have a couple datasets that I'm binding to. 1. I...
5
by: Dennis | last post by:
I am trying to create a form using databinding to a dataset and one of the fields requires the user to select from a list of optons. Any hints on how to do this other than bind the field to a...
0
by: aine_canby | last post by:
Hi, I'm trying to master databinding but I feel like I'm doing it all wrong. I have a combo which allows me to select a test. I also have the ability to add a test which should result in its...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.