filmov
tv
Multi Column Combo box in C Sharp

Показать описание
public object DataSource { get; set; }
private BindingSource bindingSource1 = new BindingSource();
private static DataTable GetData(string sqlCommand)
{
string connectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=school;Persist Security Info=True;";
SqlConnection northwindConnection = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand(sqlCommand, northwindConnection);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = command;
DataTable table = new DataTable();
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
adapter.Fill(table);
return table;
}
private void frm_book_Load(object sender, EventArgs e)
{
bindingSource1.DataSource = GetData("select id,code from subject");
comboTree1.DataSource = bindingSource1;
}
private BindingSource bindingSource1 = new BindingSource();
private static DataTable GetData(string sqlCommand)
{
string connectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=school;Persist Security Info=True;";
SqlConnection northwindConnection = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand(sqlCommand, northwindConnection);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = command;
DataTable table = new DataTable();
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
adapter.Fill(table);
return table;
}
private void frm_book_Load(object sender, EventArgs e)
{
bindingSource1.DataSource = GetData("select id,code from subject");
comboTree1.DataSource = bindingSource1;
}