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

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
correctly.

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

Here is the Form Constructor:
public TestcaseEntry(CurrentUser p_User,
CurrentProject p_Project, string p_CaseSelection)
{
//
// Required for Windows Form
Designer support
//
InitializeComponent();

this.m_User = p_User;
this.m_Project = p_Project;
this.m_CaseSelection = p_CaseSelection;

this.m_TestTypes = TestTypes.GetTypes
();
this.m_TestTypeView = new DataView
(this.m_TestTypes.TypeList);
this.m_TestTypeView.Sort = "Category";

this.m_Programs = Programs.GetProgramList ();

this.m_CaseList = Testcases.GetCaseList
(p_CaseSelection);
this.m_RecordCount = this.m_CaseList.Count;
this.m_RecordIndex = 0;

this.m_Testcase = new Testcases ();

this.m_Testcase.SetAuthorInfo (this.m_User.ID,
this.m_User.AuthorString);

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

// Set the Datasource property for the Items
collection and bind this TestTypeCategory Control to the
Testcase Record
this.m_cboTestTypeCat.DataSource =
this.m_TestTypes.CategoryList;
this.m_cboTestTypeCat.DisplayMember = "Name";
this.m_cboTestTypeCat.ValueMember = "ID";
this.m_cboTestTypeCat.DataBindings.Add
("SelectedValue",
this.m_Testcase.TestcaseList, "TestTypeCategory");

// Set the Datasource property for the Items
collection and bind this TestType Control to the Testcase
Record
this.m_cboTestType.DataSource =
this.m_TestTypeView;
this.m_cboTestType.DisplayMember = "Name";
this.m_cboTestType.ValueMember = "ID";
this.m_cboTestType.DataBindings.Add
("SelectedValue",
this.m_Testcase.TestcaseList, "TestTypeID");

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

// Bind the Textboxes to the Testcase Record
this.m_txtID.DataBindings.Add
("Text",
this.m_Testcase.TestcaseList, "TestcaseID" );
this.m_txtAuthor.DataBindings.Add
("Text",
this.m_Testcase.TestcaseList, "AuthorString" );
this.m_txtShortDescription.DataBindings.Add
("Text",
this.m_Testcase.TestcaseList, "ShortDescription");
this.m_txtDescription.DataBindings.Add
("Text",
this.m_Testcase.TestcaseList, "Description" );
this.m_txtExpRes.DataBindings.Add
("Text",
this.m_Testcase.TestcaseList, "ExpectedResult" );
this.m_txtDataProfile.DataBindings.Add
("Text",
this.m_Testcase.TestcaseList, "DataProfile" );

this.m_CurrentTestcase = (CurrencyManager)
this.BindingContext[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 7659

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

Similar topics

0
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...
13
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...
1
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
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...
3
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...
5
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...
5
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...
7
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...
0
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...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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.