473,842 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bound combobox shows wrong item

My form uses a dataset containing two tables, a base table
(Contact) and a lookup table (Insurer). My combobox is
bound as follows:

DataSource = datasetContact
DisplayMember = Insurer.Insurer Name
ValueMember = Insurer.Insurer Id
DataBindings.Se lectedValue = Contact.Insurer Id

It generally works fine. I am able to navigate records and
it displays the correct bound item. I can even update data
using the combobox and save it to the database. But, there
is a bug! When I first fill the dataset, the combobox
displays the first item in the dropdown list rather than
the item it is bound to. When I navigate to another record
and navigate back to it, the correct item is displayed in
the combobox.

Am I missing something here? How do I get the combobox to
display the correct bound item after the fill?

Help would be greatly appreciated. Thanks, Phil
****
PS
****

I found "Hemang Shah" <he****@hemang. net> also asked this
question previously on 4th August and received no answer.
He said:

Hello Friends.

I have a form which is linked to a dataset of 3 tables.
One is the base table and the other 2 are look up tables.

Now when I scroll the records, the combo box i updated
properly showing the correct lookup.

But when I click update or load, the first item in the
combobox pops up even when that particular record dosen
thtat those selected..You know what I mean ?

I'm sure everyone would be having this problem and by now
there must b a well documented fix for this, can anyone
point me to the right direction ?
Thanks.
Jul 19 '05 #1
2 3457
Sounds like you need to call the event that snychronizes
the grids after you fill your second grid, i.e.

FillGrids
Call DataGrid1.Selec tedIndex_Change d()
-----Original Message-----
My form uses a dataset containing two tables, a base table(Contact) and a lookup table (Insurer). My combobox is
bound as follows:

DataSource = datasetContact
DisplayMembe r = Insurer.Insurer Name
ValueMember = Insurer.Insurer Id
DataBindings.S electedValue = Contact.Insurer Id

It generally works fine. I am able to navigate records andit displays the correct bound item. I can even update datausing the combobox and save it to the database. But, thereis a bug! When I first fill the dataset, the combobox
displays the first item in the dropdown list rather than
the item it is bound to. When I navigate to another recordand navigate back to it, the correct item is displayed in
the combobox.

Am I missing something here? How do I get the combobox to
display the correct bound item after the fill?

Help would be greatly appreciated. Thanks, Phil
****
PS
****

I found "Hemang Shah" <he****@hemang. net> also asked this
question previously on 4th August and received no answer.
He said:

Hello Friends.

I have a form which is linked to a dataset of 3 tables.
One is the base table and the other 2 are look up tables.

Now when I scroll the records, the combo box i updated
properly showing the correct lookup.

But when I click update or load, the first item in the
combobox pops up even when that particular record dosen
thtat those selected..You know what I mean ?

I'm sure everyone would be having this problem and by now
there must b a well documented fix for this, can anyone
point me to the right direction ?
Thanks.
.

Jul 19 '05 #2
Thanks for adding a comment Alex.

Could you please add extra explanation on how it applies
to a combobox (rather than a datagrid).

Thanks,

Phil
-----Original Message-----
Sounds like you need to call the event that snychronizes
the grids after you fill your second grid, i.e.

FillGrids
Call DataGrid1.Selec tedIndex_Change d()
-----Original Message-----
My form uses a dataset containing two tables, a base

table
(Contact) and a lookup table (Insurer). My combobox is
bound as follows:

DataSource = datasetContact
DisplayMemb er = Insurer.Insurer Name
ValueMember = Insurer.Insurer Id
DataBindings. SelectedValue = Contact.Insurer Id

It generally works fine. I am able to navigate records

and
it displays the correct bound item. I can even update

data
using the combobox and save it to the database. But,

there
is a bug! When I first fill the dataset, the combobox
displays the first item in the dropdown list rather than
the item it is bound to. When I navigate to another

record
and navigate back to it, the correct item is displayed inthe combobox.

Am I missing something here? How do I get the combobox todisplay the correct bound item after the fill?

Help would be greatly appreciated. Thanks, Phil
****
PS
****

I found "Hemang Shah" <he****@hemang. net> also asked thisquestion previously on 4th August and received no answer.He said:

Hello Friends.

I have a form which is linked to a dataset of 3 tables.
One is the base table and the other 2 are look up tables.

Now when I scroll the records, the combo box i updated
properly showing the correct lookup.

But when I click update or load, the first item in the
combobox pops up even when that particular record dosen
thtat those selected..You know what I mean ?

I'm sure everyone would be having this problem and by nowthere must b a well documented fix for this, can anyone
point me to the right direction ?
Thanks.
.

.

Jul 19 '05 #3

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

Similar topics

2
9603
by: bds | last post by:
I'm new to .net 2.0 and I'm trying to figure out the best way to create a form that has a couple of controls and one of the controls is a combo box with a data bound list of items from another table. To understand the problem more, consider using the AdventureWorks2000 database. I want a simple form that shows FirstName, LastName, and Shift. Instead of the ShiftID, I want the shift name from the Shift table to be displayed. Here's...
5
4667
by: Aaron Ackerman | last post by:
I have a bound combobox the appears on a cell within the column of my bound grid when the user clicks on a cell n(In my vb.net WinForm app). I am trying to allow the adding of an item to that bound combo by allowing the user to dynamically type in the new value directly in the combo box whcih in turn updates the lookup table and then when they have finished leaves that particular cell on the grid with the correct value. Seems...
2
1420
by: Don | last post by:
I've been trying to create a custom collection that can be bound to a combobox via the DataSource property, but I can't seem to get it to work. I've created a class that implements IList, and it seems to work okay on its own, but when I try to bind it to a combobox, the combobox doesn't show anything (and it starts having problems repainting itself). The Datasource appears to contain my custom collection object, but when I ask for its item...
4
4624
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box bound to a table as a lookup, drawing values from another table to populate the available selections. This all worked fine in VB6. I have distilled the problem down to a simple form drawing data from the Northwind database for a representative...
4
309
by: Phil | last post by:
My form uses a dataset containing two tables, a base table (Contact) and a lookup table (Insurer). My combobox is bound as follows: DataSource = datasetContact DisplayMember = Insurer.InsurerName ValueMember = Insurer.InsurerId DataBindings.SelectedValue = Contact.InsurerId It generally works fine. I am able to navigate records and
2
1965
by: Crazy Cat | last post by:
I am using a data-bound combobox with dropdownstyle set to dropdownlist. Teh combobox is bound to a bindingsource which is in turn bound to a table in my database. The table has only 4 rows and I am using it to display geographical regions - Northeast, Southeast, West, and Central. In the bindingsource AddNew is set to false. Whenever I select an item from the combobox I find that the position in the dropdown list is replaced by the...
0
2023
by: Frnak McKenney | last post by:
Can I use a bound ComboBox for both browsing and editing? I'm working on a small, standalone database application using Visual C#.NET 2003 and an Access data file. In order to keep the number of different screens down to a minimum, I'm trying to use the same Windows Forms for both browsing and for updating. This works fine for TextBoxes, but I'm running into problems with my DropDownLists (ComboBoxes).
4
6667
by: Jerad Rose | last post by:
I'm baffled by this -- is there not a typed object used for ComboBox Items? Best I can tell, all of the methods for ComboBox that accept an Item are of type Object. Why in the world is a common/standard .NET control accepting an Object as a parameter type? In Web Forms, there is a ListItem object that can be passed in to add/retrieve objects from a DropDownItems collection. I searched Google groups, and all the solutions I'm finding...
1
1773
by: Robert Dufour | last post by:
I have a table of addresses and it contains a CountryId which points to a table of countries. The datatstructure of the Countries Lookup tables is actually created from three tables - a CountryIdtable - a Countries localized tables and an cultures tables From which I extract a dataset select CountryID - CountryName - Culture name (with inner joins between the three) where CultureName = CurrentCulture.CurrentUiCulture.tostring. So I would...
0
9715
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
10945
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...
0
10612
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10672
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
10314
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
7038
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5885
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4499
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 we have to send another system
2
4089
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.