c# - How to check first textbox value is in second textbox textmode -
i have 2 textboxes:
- textbox1
- textbox2
i want when first textbox have valid date second textbox's value become next week like:
if(textbox1.text== textbox2.textmode) { txtdateto.text = datetime.parse(txtdatefrom.text, system.globalization.cultureinfo.invariantculture).adddays(7).tostring("mm/dd/yyyy"); }
use textchanged event of txtdatefrom like:
private void txtdatefrom_textchanged(object sender, eventargs e) { var styles = datetimestyles.none; datetime datevalue; if(datetime.tryparse(txtdatefrom.text, system.globalization.cultureinfo.invariantculture, styles, out datevalue)) { textbox2.text = convert.tostring(datevalue.adddays(7)); } else { textbox2.text = "invalid datetime inserted in txtdatefrom;"; } }
make sure connect event correctly, example using designer @ event section of textbox.
Comments
Post a Comment