我无法从form2组合框中获得价值。我检查了组合框修改器设置为“公共”。
我得到'对象没有引用对象的实例'错误。这是什么错误?
//Form1
private DialogIO dio;
private void uosIO_ValueChanged(object sender, EventArgs e)
{
dio = new DialogIO();
dio.Show(); // Open Form2 and Set Some value on Combobox
}
// BGWorker get run call from form2 and run it on form1.
private void bgwCustomIO_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
MessageBox.Show(dio.uceMinHour.Text); // Show Combobox Value
}
答案 0 :(得分:0)
考虑检查null也是......
private void bgwCustomIO_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
if (dio == null || string.IsNullOrEmpty(dio.uceMinHour.Text))
{
return;
}
MessageBox.Show(dio.uceMinHour.Text); // Show Combobox Value
}