473,803 Members | 3,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1460
* 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.microso ft.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.Bindi ngContext = New BindingContext( )

"chris in grimsby" <gr************ @lycos.com> wrote in message
news:8a******** *************** ***@posting.goo gle.com...
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
4783
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 thought I might try some of you guys since you also deal with the Visual part of visual basic and since vba shouldn`t be all that different from vb.... (I changed the order of the post and edited the junk out a bit to make it a bit more readable but...
7
8538
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 of doing it. I have a table with products, tblProducts, some of them are Active while others are Inactive. The form shows all the products purchased by a customer, both Active and Inactive in a ComboBox, cbProducts. My client wants to view all...
3
6837
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: http://msdn.microsoft.com/msdnmag/issues/03/08/DataGrids/default.aspx I have a problem when there are two DataGrid's on one form, and when I switch focus from one grid to the other. To be more precise, when I'm editing a combo box column in one grid, and then click in the combo column of...
4
4020
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 - but contain a value. However the value is just for user reference - not really one of the combobox choices. For example intially the combobox should equal the word Select - and the item values can be say 'one', 'two', and 'three'.
30
4608
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 corresponding field in the lookup table. In my data table we store the ID in what I will call the 'key' field. == Description of the desired operation:
0
1712
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. even if I abitrarily set the combobox text to empty string, the value retrieved from the combobox text is still the first row value from the list. How can I set, when I display this combobox, the default display text to be empty, instead of the...
0
3176
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 the information that I get from a text file. I then try to set the value of the combobox to a specific value based on the first column. The code is working to set the value, but it will not refresh and display the selected value on the screen...
8
26441
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 datagridview control? I am at a loss. Thanks, David
5
6790
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 selected index to the item (without adding a duplicate). I know the basics of inheriting from user controls, so if this was merely overriding a method of ComboBox I could do it. But how does one go about overriding a method of the Items...
2
2576
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 the same dataset. I can start the form and cycle through existing records. If I click on one of the comboboxes it will display the text values but then I can no longer click on any other field. I can continue to click on the same combobox and the...
0
9703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9566
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10555
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10300
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9127
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7607
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.