dotnetmonitor.com |
|
||||||||||||
| /*
Create a new Customer (customer has Name */
/* and StateID properties) */ Customer cust = new Customer("Joe", "WA");
/* Bind the States ComboBox to the states DataTable */ /* Display the "Name" property in the ComboBox */ /* Use the "Code" property as the "Key" *
/* StatesTable contains US state information */ /* Name = full state name */ /* Code = state unique key */ this.statesCB.DisplayMember = "Name"; this.statesCB.ValueMember = "Code"; this.statesCB.DataSource = statesTable;
/* Set the default States ComboBox selected value */ /* to the Customer's StateID ("WA") */ /* This will make the ComboBox show "Washington" */ /* If the States ComboBox is changed, the Customer */ /* StateCode will be automatically updated */ this.statesCB.DataBindings.Add("SelectedValue", cust, "StateID", true); |
||||||||||||
|
||||||||||||