Feb
5
Written by:
Renegade
Friday, February 05, 2010 12:14 PM
So, here we go:
1: private void button_Click(object sender, EventArgs e)
2: {
3: ((Button)sender).Enabled = false;
4: txtSomething.Text = System.Guid.NewGuid().ToString();
5: ((Button)sender).Enabled = true;
6: }
Pretty easy, eh?
In the click event, the button is sent as the "sender". You must cast that as a Button, (Button)sender, then simply treat it like a button and access the Enabled property.
The second thing in there is getting a GUID string. Real easy. System.Guid.NewGuid().ToString(). Nothing hard there. Just remember not to use the "new" keyword.
I hope that helps somebody out.
Cheers,
Ryan
Copyright ©2010 Ryan Smyth
Tags: