chumzzz

chumzzz

  • NA
  • 16
  • 0

Combo boxes and Datasets

Jan 12 2004 11:33 AM
I have a Windowsform based on a table "Agency". On this form I have 2 combo boxes each of which is used to populate values into 2 fields in the base table "Agency". The combo boxes however derive the list of values from another table "codelookup". THe form has 2 datasets one based on the "Agency" table (agencyds) and the other based on the "codelookup" table (codelookupds). The combo boxes are based off the codelookupds dataset and the (windows) form is based off the agencyds dataset. On Next and Previous button events (after loading data into the form), I am trying to ensure that the combo box displays the value as in the database and not its default drop-down value. Some code is given below: private void btnNavPrev_Click(object sender, System.EventArgs e) { int lRIndex=0; this.BindingContext[agencyds,"Agency"].Position = (this.BindingContext[agencyds,"Agency"].Position - 1); this.agencyds_PositionChanged(); this.comboBoxRACONTACT1.SelectedText = agencyds.Agency[lRIndex].RACONTACT1; this.comboBoxRACONTACT2.SelectedText = agencyds.Agency[lRIndex].RACONTACT2; } Similar code is associated with the btnNavNext_Click event. But the display in the combo boxes is a concatenated value of what is in the Agency table and the default value of the combo box. For instance the combo box displays "Home" by default. But if the value in the database table column is "Cell", the display on the above Next/Prev events shows "CellHome". I am probably using the incorrect property of the combo box to do this assignment. Any help in resolving this will be appreciated.