【问题标题】:Combobox selectedValue crashes ControlBox in C#Combobox selectedValue 使 C# 中的 ControlBox 崩溃
【发布时间】:2014-02-16 15:05:32
【问题描述】:

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

【问题讨论】:

  • 添加了更多代码...请帮助

标签: c# winforms combobox controlbox


【解决方案1】:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    string databaseName = string.Empty;
    if(comboBox1.SelectedItem != null) databaseName = comboBox1.SelectedItem.ToString();
}

【讨论】:

  • 谢谢@Sameer,你来自哪里?
猜你喜欢
  • 2017-11-02
  • 1970-01-01
  • 2012-06-23
  • 1970-01-01
  • 2011-04-21
  • 1970-01-01
  • 2016-08-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多