我这样填充组合框。想先成为空。我怎么能这样做?
private void txtLoadname_DropDown(object sender, EventArgs e)
{
HashSet<string> LoadName = new HashSet<string>();
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
LoadName.Add(dataGridView1.Rows[i].Cells["loadNameDataGridViewTextBoxColumn"].Value.ToString());
}
txtLoadname.DataSource = LoadName.ToList();
}
答案 0 :(得分:1)
尝试添加LoadName.Add(null);在循环之前。
答案 1 :(得分:1)
在最后一行之前添加此行:
LoadName.InsertAt(0,"");