Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Databinding and SelectValueMember not updating DS

Status
Not open for further replies.

CrashDome

Technical User
Jan 7, 2002
86
US
I currently have two tables:

JobCenter (holds a job number and more importantly - CustomerID pertaining to that job)

Customer (holds addresses etc... with a PK CustomerID)

I created a ComboBox called "custName" and did the following:

this.CustName.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.dsJobCenter, "JOBCENTER.CustID"));
this.CustName.DataSource = this.dsJobCenter;
this.CustName.DisplayMember = "CUSTOMERS.CompanyName";
this.CustName.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.CustName.Location = new System.Drawing.Point(80, 24);
this.CustName.Name = "CustName";
this.CustName.Size = new System.Drawing.Size(344, 24);
this.CustName.TabIndex = 12;
this.CustName.ValueMember = "CUSTOMERS.CustID";


I apologize for the bad copy/paste...
but anyway,

The Customers show up in the combobox and the current customer for the job is automatically selected and shown.
HERE IS MY ISSUE: When you change the customer, it doesn't update the dataset.
I placed a datagrid on the same form to view what was going on and it wasn't updating the record UNTIL I clicked somewhere on the datagrid!!! Now, I am trying to figure out what method is called when I click on the datagrid that I can assign to my on_SelectValueChanged even so it updates right away. (and it is NOT the DataSet.Update() method)

Any help appreciated.
 
got it....

Needed to add this to a desired event (such as SelectedValueChanged, SelectionCommitted, a "Save" Button, etc..):

this.CustName.DataBindings["SelectedValue"].BindingManagerBase.EndCurrentEdit();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top