private void difficulty_Click(object sender, EventArgs e)
{
int handle;
Control ctl;
if (sender is Control)
ctl = (Control) sender;
}
On 3/19/07, Paul <[EMAIL PROTECTED]> wrote:
Hi,
I'm trying to find a way to use one method to replace a number. I have
two menus, one for difficulty and the other chooses a test. If I wanted
to handle each menu click, I could use a whole pile of events, but I'd
rather use one which catches everything.
When I've done this sort of thing in VB, I've done something like
this...
Private Sub LotsOfButtons(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click
Dim clickedCtrl As Control
If TypeOf sender Is Control Then
clickedCtrl = DirectCast(sender, Control)
MsgBox(clickedCtrl.Text)
End If
End Sub
Okay, DirectCast doesn't exist in C#. What would I need to use to
convert this over to C#? My current code is a bit of a mess
private void difficulty_Click(object sender, EventArgs e)
{
int handle;
Control ctl = new Control();
if (sender is Control)
// at this point, I'd do the directcast
}
What do I need to do here?
TTFN
Paul
--
Sie können mich aufreizen und wirklich heiß machen!
_______________________________________________
Mono-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list
--
Juan Cristóbal Olivares
_______________________________________________
Mono-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list