473,386 Members | 1,958 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,386 software developers and data experts.

Combobox default problem

I have a combobox of dropdownlist style as one of the controls on a
tabbed form.

The list is populated by setting the DataSource property to a dataset
and then the DisplayMember and ValueMember properties are set to the
names of 2 of the fields in the dataset.

I noticed that when the form displays, the combobox defaults to the
first item in the list, not to blank (selectedindex=-1) as I would
have expected. I can use the Form_Activated event to set the
selectedindex=-1 and that is ok, until a different tab is selected
followed by this tab. Now the selectedindex=0 again and the combobox
shows the first item in the list again, even though the index change
event didnt fire.
Nov 20 '05 #1
2 1444
* gr************@lycos.com (chris in grimsby) scripsit:
The list is populated by setting the DataSource property to a dataset
and then the DisplayMember and ValueMember properties are set to the
names of 2 of the fields in the dataset.

I noticed that when the form displays, the combobox defaults to the
first item in the list, not to blank (selectedindex=-1) as I would
have expected. I can use the Form_Activated event to set the
selectedindex=-1 and that is ok, until a different tab is selected
followed by this tab. Now the selectedindex=0 again and the combobox
shows the first item in the list again, even though the index change
event didnt fire.


BUG: ComboBox Does Not Clear When You Set SelectedIndex to -1
<URL:http://support.microsoft.com/?id=327244>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
I have also experienced this issue with MDI child forms. The fix is the same
as for tab controls:
give the combobox a different binding context to the form (which is the
default). e.g.

comboBox1.BindingContext = New BindingContext()

"chris in grimsby" <gr************@lycos.com> wrote in message
news:8a**************************@posting.google.c om...
I have a combobox of dropdownlist style as one of the controls on a
tabbed form.

The list is populated by setting the DataSource property to a dataset
and then the DisplayMember and ValueMember properties are set to the
names of 2 of the fields in the dataset.

I noticed that when the form displays, the combobox defaults to the
first item in the list, not to blank (selectedindex=-1) as I would
have expected. I can use the Form_Activated event to set the
selectedindex=-1 and that is ok, until a different tab is selected
followed by this tab. Now the selectedindex=0 again and the combobox
shows the first item in the list again, even though the index change
event didnt fire.

Nov 20 '05 #3

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

Similar topics

1
by: Oren Kaplan | last post by:
Hello, I posted a msg on the Access-related groups in hope someone there could help me but since almost two days have past and I didnt get a response (Im a bit hard pressed with the problem) I...
7
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
3
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
4
by: Keith | last post by:
Hello - this started out as a minor annoyance - and now is starting to bother me more and more - I'm hoping someone can help me. I would like to have a combobox display - NOT initially be blank...
30
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
0
by: yalanue | last post by:
I want to create a combobox with its displaymember populated from a datatable. But once I get it run, the default display member in the combobox is always the first row of the displaymember list....
0
by: lv2compute | last post by:
I am having a problem with my datagridview. I have a small table that has two columns. The first column is bound to my dataset. The second column is a combobox. I add items to the combobox based on...
8
by: | last post by:
I am sure this has been asked and answered, but here goes anyway... VS.Net 2005, VB.Net How can you display more than one field in the displaymember property of a combobox inside the...
5
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I want to create a customized ComboBox where the methods ComboBox.Items.Add and ComboBox.Items.Insert will behave thusly: -- If the item is not present, add it. -- If the item is present, set the...
2
by: =?Utf-8?B?SmFtZXMgTWFydGlu?= | last post by:
I have a table that I dragged onto a form from a dataset. I changed some of the fields to comboboxes and set the data source, display member (text), and value member (int) to another table within...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.