当我从我的组合框中分配所选值时,我的Winforms应用程序不会通过controlBox
关闭(最小化,最大化工作但不关闭!)
如果我注释掉以下代码,它似乎有效:
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'dataSet1.NewSelectCommand' table. You can move, or remove it, as needed.
this.newSelectCommandTableAdapter.Fill(this.dataSet1.NewSelectCommand);
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string databaseName = string.Empty;
databaseName = comboBox1.SelectedItem.ToString();
}
答案 0 :(得分:2)
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string databaseName = string.Empty;
if(comboBox1.SelectedItem != null) databaseName = comboBox1.SelectedItem.ToString();
}