0

当我从我的组合框中分配选定的值时,我的 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();
    }
4

1 回答 1

2
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    string databaseName = string.Empty;
    if(comboBox1.SelectedItem != null) databaseName = comboBox1.SelectedItem.ToString();
}
于 2014-01-25T16:46:41.103 回答