private void button1_Click(object sender, System.EventArgs e) { DataTable table1; DataRow row1, row2, row3, row4; table1 = new DataTable("Customers"); DataColumn firstName = new DataColumn("First Name"); firstName.DataType = System.Type.GetType("System.String"); table1.Columns.Add(firstName); DataColumn lastName = new DataColumn("Last Name"); lastName.DataType = System.Type.GetType("System.String"); table1.Columns.Add(lastName); DataColumn phone = new DataColumn("Phone"); phone.DataType = System.Type.GetType("System.String"); table1.Columns.Add(phone); DataColumn id = new DataColumn("ID"); id.DataType = System.Type.GetType("System.Int32"); table1.Columns.Add(id); row1 = table1.NewRow(); row1["First Name"] = "A"; row1["Last Name"] = "B"; row1["Phone"] = "(555) 333-4444"; row1["ID"] = 1; table1.Rows.Add(row1); row2 = table1.NewRow(); row2["First Name"] = "B"; row2["Last Name"] = "C"; row2["Phone"] = "(555) 333-4445"; row2["ID"] = 2; table1.Rows.Add(row2); row3 = table1.NewRow(); row3["First Name"] = "E"; row3["Last Name"] = "R"; row3["Phone"] = "(555) 333-4445"; row3["ID"] = 3; table1.Rows.Add(row3); row4 = table1.NewRow(); row4["First Name"] = "W"; row4["Last Name"] = "K"; row4["Phone"] = "(555) 333-4447"; row4["ID"] = 4; table1.Rows.Add(row4); DataSet dataset1 = new DataSet(); dataset1.Tables.Add(table1); dataGrid1.SetDataBinding(dataset1, "Customers"); } }
dataGrid1.DataSource=dataset1.Tables[0] ;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)