简体   繁体   中英

Combobox selectedValue crashes ControlBox in C#

When ever i assign the selected value from my combo box my Winforms application wont close via the controlBox (Minimise, Maximise work but close does not!)

If i comment out the following code it seems to work:

    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();
    }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    string databaseName = string.Empty;
    if(comboBox1.SelectedItem != null) databaseName = comboBox1.SelectedItem.ToString();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM