473,486 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2144
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
2805
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
2425
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
1169
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
1386
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
259
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
3602
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
994
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
1805
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
2672
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
6964
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
7123
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,...
1
6842
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
7319
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...
0
5430
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4864
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.