我有四个组合框,我想用从同一张表带来的相同数据填充它们,但这项任务在袖珍 PC 设备上需要很多时间。所以我想知道是否有比这更快的方法:
private void autreform_Load(object sender, EventArgs e)
{
DataTable dtable = new DataTable();
SqlDataAdapter adapter = new SqlDataAdapter("select designation, num_produit from STK_PRODUITS_GENERIQUE where num_famille in (select num_famille from parametrage_vidange where produit='autres') ", mySqlConnection1);
adapter.Fill(dtable);
try
{
remplircombo(comboBox1, dtable);
remplircombo(comboBox2, dtable);
remplircombo(comboBox3, dtable);
remplircombo(comboBox4, dtable);
}
catch (Exception excr) { MessageBox.Show(excr.Message); }
}
private void remplircombo(ComboBox combo, DataTable dtable )
{
combo.DataSource = new BindingSource(dtable, null);
combo.DisplayMember = "designation";
combo.ValueMember = "num_produit";
}