关于一段程序的理解 关于combobox
namespace TwoComboBoxs{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
NorthwindDataSet.ProductsDataTable productTable = new NorthwindDataSet.ProductsDataTable();
NorthwindDataSet.CategoriesDataTable categoryTable = new NorthwindDataSet.CategoriesDataTable();
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
DataRowView rowView = comboBox1.SelectedItem as DataRowView;
NorthwindDataSet.CategoriesRow row = rowView.Row as NorthwindDataSet.CategoriesRow;
int id = row.CategoryID;
productTable.DefaultView.RowFilter = string.Format("CategoryID = {0}", id);
}
private void Form1_Load(object sender, EventArgs e)
{
NorthwindDataSetTableAdapters.CategoriesTableAdapter categoryAdapter = new TwoComboBoxs.NorthwindDataSetTableAdapters.CategoriesTableAdapter();
categoryAdapter.Fill(categoryTable);
= categoryTable.DefaultView;
comboBox1.DisplayMember = categoryTable.CategoryNameColumn.ColumnName;
NorthwindDataSetTableAdapters.ProductsTableAdapter productAdapter = new NorthwindDataSetTableAdapters.ProductsTableAdapter();
productAdapter.Fill(productTable);
= productTable.DefaultView;
comboBox2.DisplayMember = productTable.ProductNameColumn.ColumnName;
}
}
}
这里面用的是northwind,看不太懂,有没有sql server 相关的语句可以替换一下的