C# Checking if button was clicked -
i making program, should continue, if 2 conditions given. first 1 2 textboxes have same word in , button clicked, opens new form. see trying make registration form ;) have event "complete" button.
private void button2_click(object sender, eventargs e) { if (textbox2.text == textbox3.text && ???) { streamwriter mywriter = file.createtext(@"c:\program files\text.txt"); mywriter.writeline(textbox1.text); mywriter.writeline(textbox2.text);
my problem is, cant find method, gives button1.clicked or similiar.
i hope can me here..
click
event fires after release mouse button. if want check in handler button2.click
if button1
clicked before, have handler button1.click
sets bool flag of own making true.
private bool button1wasclicked = false; private void button1_click(object sender, eventargs e) { button1wasclicked = true; } private void button2_click(object sender, eventargs e) { if (textbox2.text == textbox3.text && button1wasclicked) { streamwriter mywriter = file.createtext(@"c:\program files\text.txt"); mywriter.writeline(textbox1.text); mywriter.writeline(textbox2.text); button1wasclicked = false; } }
Comments
Post a Comment