473,847 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataBinding Issue with ComboBox

I have a Windows Form Which Displays one record at a
time. The DataTable object which is bound to the Form
Controls only contains the record that is being
displayed. When I need to display a different record, any
changes in the current record are saved to an Access
Database, the DataTable's Row Collection is Cleared and
the New Record is read into the DataTable. (This is done
to ensure that when the User goes to view a record, they
get the most current version of that record).

The Problem I am having is that when the Windows Form
contains a ComboBox, when the form is initially loaded,
the First record is correctly displayed. However, as soon
as I move to another record, all of the controls are
blank, even when I move back to the original record. This
is not a case of the underlying DataTable not being
filled correctly, since while stepping through the code
in the debugger, I checked the DataTable and it contained
the correct information.

I have another form that using this same method to
display records, and it functions perfectly. The only
difference is that this form contains ComboBoxes, and the
Other form doesn't. When I remove the DataBinding
statements for the ComboBoxes, this form functions

Ironically, I initially stored the data in XML files, and
this form functioned correctly.

Here is the Form Constructor:
public TestcaseEntry(C urrentUser p_User,
CurrentProject p_Project, string p_CaseSelection )
// Required for Windows Form
Designer support
InitializeCompo nent();

this.m_User = p_User;
this.m_Project = p_Project;
this.m_CaseSele ction = p_CaseSelection ;

this.m_TestType s = TestTypes.GetTy pes
this.m_TestType View = new DataView
(this.m_TestTyp es.TypeList);
this.m_TestType View.Sort = "Category";

this.m_Programs = Programs.GetPro gramList ();

this.m_CaseList = Testcases.GetCa seList
(p_CaseSelectio n);
this.m_RecordCo unt = this.m_CaseList .Count;
this.m_RecordIn dex = 0;

this.m_Testcase = new Testcases ();

this.m_Testcase .SetAuthorInfo (this.m_User.ID ,
this.m_User.Aut horString);

// Set the Datasource property for the Items
collection and bind this Program Control to the Testcase
this.m_cboProgr am.DataSource =
this.m_Programs .Selections;
this.m_cboProgr am.DisplayMembe r = "Name";
this.m_cboProgr am.ValueMember = "ID";
this.m_cboProgr am.DataBindings .Add
("SelectedValue ",
this.m_Testcase .TestcaseList, "ProgramID" );

// Set the Datasource property for the Items
collection and bind this TestTypeCategor y Control to the
Testcase Record
this.m_cboTestT ypeCat.DataSour ce =
this.m_TestType s.CategoryList;
this.m_cboTestT ypeCat.DisplayM ember = "Name";
this.m_cboTestT ypeCat.ValueMem ber = "ID";
this.m_cboTestT ypeCat.DataBind ings.Add
("SelectedValue ",
this.m_Testcase .TestcaseList, "TestTypeCatego ry");

// Set the Datasource property for the Items
collection and bind this TestType Control to the Testcase
this.m_cboTestT ype.DataSource =
this.m_TestType View;
this.m_cboTestT ype.DisplayMemb er = "Name";
this.m_cboTestT ype.ValueMember = "ID";
this.m_cboTestT ype.DataBinding s.Add
("SelectedValue ",
this.m_Testcase .TestcaseList, "TestTypeID ");

// Set the DataSource Properties for the Goto
Case List
this.cboCaseLis t.DataSource =
this.m_CaseList .Selections;
this.cboCaseLis t.DisplayMember = "ID";
this.cboCaseLis t.ValueMember = "ID";

// Bind the Textboxes to the Testcase Record
this.m_txtID.Da taBindings.Add
this.m_Testcase .TestcaseList, "TestcaseID " );
this.m_txtAutho r.DataBindings. Add
this.m_Testcase .TestcaseList, "AuthorStri ng" );
this.m_txtShort Description.Dat aBindings.Add
this.m_Testcase .TestcaseList, "ShortDescripti on");
this.m_txtDescr iption.DataBind ings.Add
this.m_Testcase .TestcaseList, "Descriptio n" );
this.m_txtExpRe s.DataBindings. Add
this.m_Testcase .TestcaseList, "ExpectedResult " );
this.m_txtDataP rofile.DataBind ings.Add
this.m_Testcase .TestcaseList, "DataProfil e" );

this.m_CurrentT estcase = (CurrencyManage r)
this.BindingCon text[this.m_Testcase .TestcaseList];


The Only solution I can think of right now is to not
perform the DataBind for the ComboBoxes, and everytime, I
get a new record, locate the appropriate entry in each of
these comboboxes, and when the value in the comboboxes is
changed by the user, to in code update the appropriate
field in the record. Is there another solution??????

Nov 15 '05 #1
0 7688

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

Similar topics

by: Richard | last post by:
Hi, I'm having issues with DataBinding. I have a Form with two data bound comboboxes on it. When you select something in one combobox I may {or may not} want to change the selected item in the other combobox. For reasons beyond the scope of this post I need to change the second comboboxe's selected index from within a ColumnChanging event handler. So, inside a ColumnChanging event handler I change the value of the column that is bound to...
by: Michael Maes | last post by:
Hi, I have a UserControl containing some controls of which one is a ComboBox. All the InternalControls are Private and some are allowed to be accessed through Public Methods. One of the things I would like to do (of course) is set the DataBindings. Something clearly is wrong with the approach I use, because I can't set the Properties in the Designer, the DataSource-Property appears like 'ReadOnly', there is no "dropdown" with the list from...
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". Each combobox has its datasource, displaymember and SelectedValue member bound to separate tables thru individual datatsets thru individual data adapters. The two tables are "Class" and "SubClass". I use parameterized query to populate the...
by: Kevin Hodgson | last post by:
I have a ComboBox and a TextBox bound to a Dataset/datatable returned from a SQL Database. The databinding is set in Design Mode. Everything works fine on my initial fill, and I get the correct list of items in the combobox, and the textbox which is bound to a second column in the same table, changes to the appropriate value when a new item is selected in the ComboBox. The ComboBox is displaying a list of products, and the texbox the...
by: Dan Slaby | last post by:
I have a webservice that I want to populate a combobox on a windows form. The webservice creates the correct XML output, but when I attempt to bind it to a combobox I get this error: Additional information: Cannot bind to property or column FullName on DataSource. This error occurs with the databindings. Here is the code: --
by: Peter M. | last post by:
I'm struggling with combobox databinding with something I consider a bug... I'm binding my combobox to an array of structs. The struct exposes two public properties, ID and Name, to be used as the value and displaymember properties. This works fine. My combobox contains the correct data. However I'm also binding my SelectedValue property to a column in a datatable. Here's where I'm lost. The combobox doesn't show the correct
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 label or text box to display the current field value then add a combo box with the list of items to chose from? -- Dennis in Houston
by: JTC^..^ | last post by:
When i attempt to bind to the "Text" and "Value" property of a combobox on a windows form the value is reset when I leave the combobox. The comboboxes contain the correct Text and Values. I know this as the Value property binds correctly on it own. It is only when I bind the "Text" and "Value" that the issue occurs. The following sample code includes my custom classes and the Form Clode. I have several comboboxes and customer classes...
by: theleshie | last post by:
Hi, I am creating an application which dynamically creates forms depending on the information held in a dataset (which also includes the data the application itself uses). As part of dynamically creating these forms, I need to bind controls back to their underlying tables. This has been successful with textboxes, but I am having a lot of difficulty with comboboxes. Setting the datasource to the bindinglist seems to be ok, but I am having...
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...
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...
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,...
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...
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...
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...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.