VS C# 怎样一次性给多个COMBOBOX控件添加ITEMS?

就像在VB6.0中应用控件数组给相同的控件赋值一样,VS中应该怎样写?

1个回答

 ComboBox[] cbs = new ComboBox[] { comboBox1, comboBox2, ... };
string[] items = { "a", "b", "c" };
foreach (var cb in cbs)
{
foreach (var item in items)
cb.Items.Add(item);
}

如果问题解决,请点下我回答右边的采纳,谢谢

立即提问