Disabling command button when value of text/combo is null

I’ve created a form that connects to a database, however, I do not want blank data being submitted.

The problem I’m having is that when the combobox is completed the command/submit button is enabled even though the textbox remains incomplete. Can someone please assist? Thanks.

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.SelectedItem + textBox2.Text ==null) { button1.Enabled = false; } else { button1.Enabled = true; } }

submitted by /u/hobospells
[link] [comments]

Leave a Reply