Handles in C# ?
-
Hey on vb we use Handles to handle code with many controls , Now one C# I want to handle a code with some textboxes keydown event then what can I do .. I feel that vb is more easy in coding than c#
jooooo
-
Hey on vb we use Handles to handle code with many controls , Now one C# I want to handle a code with some textboxes keydown event then what can I do .. I feel that vb is more easy in coding than c#
jooooo
Hi, try simply adding the same event handler to several text boxes using properties window in designer. For furher study, investigate the generated designer.cs code. With a little effort you get the idea what happens at code level. Hope this get's you going. Mika
-
Hey on vb we use Handles to handle code with many controls , Now one C# I want to handle a code with some textboxes keydown event then what can I do .. I feel that vb is more easy in coding than c#
jooooo
Hi, if you have the same event handler for several Controls (either through Designer, or by code), then the event handler can figure out which Control fired the event by looking at the first parameter
object sender
. Say e.g. all Controls firing this event are Buttons, then simply doButton btn=(Button)sender;
and you are holding the Button that fired the event. You may want to be more defensive and use theas
instead of a straight cast though. :)Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
-
Hi, try simply adding the same event handler to several text boxes using properties window in designer. For furher study, investigate the generated designer.cs code. With a little effort you get the idea what happens at code level. Hope this get's you going. Mika
thanks my friend and i will check it now
jooooo
-
Hi, if you have the same event handler for several Controls (either through Designer, or by code), then the event handler can figure out which Control fired the event by looking at the first parameter
object sender
. Say e.g. all Controls firing this event are Buttons, then simply doButton btn=(Button)sender;
and you are holding the Button that fired the event. You may want to be more defensive and use theas
instead of a straight cast though. :)Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
thanks my friend you are right to use
sender
now I'm checking it and thanks for really kinds friends herejooooo
-
thanks my friend you are right to use
sender
now I'm checking it and thanks for really kinds friends herejooooo
You're welcome. Enjoy C#! :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
-
thanks my friend and i will check it now
jooooo