In Windows Form , I Created ComboBox, when i try to Create a new name, it doesn't show any output. Instead of that it is showing " System.NullReferenceException : 'Object reference is not set to an instance of an object.
private void btnCountry_Click(object sender, EventArgs e)
{
MessageBox.Show(comboBox1.Text);
MessageBox.Show(comboBox1.SelectedItem.ToString());MessageBox.Show(comboBox1.SelectedIndex.ToString());
this.Close();
}
private void btnStates_Click(object sender, EventArgs e)
{
foreach(object obj in listBox1.SelectedItems)
{
MessageBox.Show(obj.ToString());
}
}

Piyush PansuriyaRank #454 · 5.5K reputationPosted Oct 31, 2018, 10:22 PM EDT
Sreekanth ReddyRank #726 · 3.2K reputationPosted Oct 31, 2018, 7:25 PM EDT
Laxmidhar SahooRank #383 · 6.6K reputationPosted Oct 31, 2018, 9:50 PM EDT
Suraj KumarRank #353 · 7.1K reputationPosted Oct 31, 2018, 11:11 PM EDT
Laxmidhar SahooRank #383 · 6.6K reputationPosted Oct 31, 2018, 11:28 PM EDT