I am making a program that should just continue if 2 conditions are given.
The first one, 2 TextBox
s have the same word in and a Button
was clicked, which opens a new Form
. Now I have the event for the "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, I can't find a method that gives something like `button1.Clicked or something similar.
I hope someone can help me here..
Click
is an event that fires immediately after you release the mouse button. So if you want to check in the handler for button2.Click
if button1
was clicked before, all you could do is have a handler for button1.Click
which sets a bool flag of your own making to 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;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With