这些之间有什么区别?我可以使用这些方法中的任何一种在标签中显示组合框的文本,或者有什么区别吗?
label1.Text = comboBox1.SelectedItem.ToString();
label2.Text = comboBox1.Text;
label3.Text = comboBox1.SelectedValue.ToString();
Run Code Online (Sandbox Code Playgroud)
我正在测试组合框的这些值,但我对它们的工作原理感到困惑。我想在标签中显示组合框的文本。使用comboBox.Text它工作正常,但其余两个给出以下错误:
error message:Object reference not set to an instance of an object.
Run Code Online (Sandbox Code Playgroud)