|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
understanding the sender objectHello
dot.net winforms How Do I make casting from the sender object to controls in the form that called the sub ? "romy" <romy1***@hotpop.com> schrieb: If you use a common handler for controls of different type:> How Do I make casting from the sender object to controls in the form that > called the sub ? \\\ Select Case True Case TypeOf sender Is Button Dim SourceControl As Button = DirectCast(sender, Button) ... Case TypeOf sender Is ListBox Dim SourceControl As ListBox = DirectCast(sender, ListBox) ... End Select /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Romy,
A sender can be any object. In the case of the control you know it mostly therefore you can than set forever if it is by instance a button \\\ directcast(sender,button1).Performclick /// However if you need by instance the text from a control than this is as well enough \\\ directcast(sender,control).Text /// Text is in every control. I hope this helps, Cor |
|||||||||||||||||||||||