i got a combobox store list of item ( not using data bound ), a button used to clear all of the text of combobox and textbox, with a few textbox
when i press on the clear button, it show me this error message :
An unhandled exception of type 'System.NullReferenceException' occurred in bookbar user interface.exe
Additional information: Object reference not set to an instance of an object.
What I have tried:
this is my code
code for my button :
private void button1_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
comboBox1.SelectedIndex = -1;
}
i also set some code in the event of combobox, SelectedIndexChanged, this is where the error message show
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) {
if (comboBox1.SelectedItem.ToString() != "Lain-lain") {
textBox1.Clear();
}
else {
textBox1.Enabled = true;
}
updatebooknameList();
}