winforms - How to enable a button that is disabled based on textBox? c# -
i got textbox load value database , button update changes based on value of textbox. need enabled button if textbox value changed. example, value textbox loads 3 if input again 3 in textbox button still disable. button enabled if changed value example 4 or number not 3.
cache original value somewhere compare in textchanged event
private void textbox1_textchanged(object sender, eventargs e) { if (textbox1.text == originalvalue) { button1.enabled = false; } else { button1.enabled = true; } }
alternatively, (see codesinchaos' comment below):
private void textbox1_textchanged(object sender, eventargs e) { button1.enabled = textbox1.text != originalvalue; }
Comments
Post a Comment