dotnetmonitor.com

 
Index
Previous
Next

 

/* Create a new Customer */

Customer cust = new Customer("Joe", null);

 

/* Add null value */

DataRow row = statesTable.NewRow();

 

/* Enter a null row (ComboBox will show blank) */

row["Name"] = "";

row["Code"] = DBNull.Value;

 

/* Add the row to DataTable */

statesTable.Rows.Add(row);

 

/* Bind the States ComboBox to the states DataTable */

this.statesCB.DisplayMember = "Name";

this.statesCB.ValueMember = "Code";

this.statesCB.DataSource = statesTable;

 

/* Bind the ComboBox SelectedValue to the customer */

/* business object */

this.statesCB.DataBindings.Add("SelectedValue", cust, "StateID", true);

Simple Binding
Complex Binding
Using Simple Binding with a List
Sample: Simple Binding to a List (VS 2005) (VS Project: DataBinding Intro)
Type Conversion
Formatting