Click here to Skip to main content
15,908,111 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Resize Form! Pin
Dave Kreskowiak28-Jun-06 8:46
mveDave Kreskowiak28-Jun-06 8:46 
GeneralRe: Resize Form! Pin
Assaf8228-Jun-06 10:43
Assaf8228-Jun-06 10:43 
GeneralRe: Resize Form! Pin
soodmonu28-Jun-06 18:13
soodmonu28-Jun-06 18:13 
GeneralRe: Resize Form! Pin
Dave Kreskowiak29-Jun-06 4:33
mveDave Kreskowiak29-Jun-06 4:33 
QuestionCan someone explain "ByVal sender as system.object Pin
cj433128-Jun-06 6:04
cj433128-Jun-06 6:04 
AnswerRe: Can someone explain "ByVal sender as system.object Pin
Dave Kreskowiak28-Jun-06 6:39
mveDave Kreskowiak28-Jun-06 6:39 
GeneralRe: Can someone explain "ByVal sender as system.object Pin
cj433128-Jun-06 7:53
cj433128-Jun-06 7:53 
GeneralRe: Can someone explain "ByVal sender as system.object Pin
Dave Kreskowiak28-Jun-06 8:44
mveDave Kreskowiak28-Jun-06 8:44 
It makes perfect sense that you CAN'T do it.

Look at the parameters for the event handler. The first one, sender, is n System.Object, which is essentially just a container for every type of object known. Just about EVERYTHING is a descendant of the System.Object class.

Note that the System.Object class doesn't have an Enabled property. If you just specified any old property or method, how would the compiler know how to call it?

For example, you can use the same event handler to handle multiple events for multiple controls. They don't ALL have to be buttons. You can have a mix of buttons, checkboxes, panels, ..., anything else all using the same Click event handler. You can also mix events. The same handler can handle multiple types of events, so long as every event signature (parameters) is the same.

Now, knowing this, how is the compiler supposed to know what kind of object to automagically cast the sender parameter to in order to call it's properties and methods?


Dave Kreskowiak
Microsoft MVP - Visual Basic

GeneralRe: Can someone explain "ByVal sender as system.object Pin
cj433128-Jun-06 9:28
cj433128-Jun-06 9:28 
AnswerRe: Can someone explain "ByVal sender as system.object Pin
Guffa28-Jun-06 10:19
Guffa28-Jun-06 10:19 
GeneralRe: Can someone explain "ByVal sender as system.object Pin
cj433128-Jun-06 10:25
cj433128-Jun-06 10:25 
AnswerRe: Can someone explain "ByVal sender as system.object Pin
Guffa28-Jun-06 10:39
Guffa28-Jun-06 10:39 
GeneralRe: Can someone explain "ByVal sender as system.object Pin
Dave Kreskowiak28-Jun-06 10:43
mveDave Kreskowiak28-Jun-06 10:43 
GeneralRe: Can someone explain "ByVal sender as system.object Pin
Guffa28-Jun-06 11:53
Guffa28-Jun-06 11:53 
GeneralRe: Can someone explain "ByVal sender as system.object Pin
Dave Kreskowiak28-Jun-06 15:42
mveDave Kreskowiak28-Jun-06 15:42 
QuestionCreating a dinamic Menu Pin
fredy66628-Jun-06 5:16
fredy66628-Jun-06 5:16 
AnswerRe: Creating a dinamic Menu Pin
fredy6663-Jul-06 0:24
fredy6663-Jul-06 0:24 
QuestionRuntime TextBoxes Pin
mtone28-Jun-06 4:49
mtone28-Jun-06 4:49 
QuestionVS 2005 and ReportServer Pin
VK-Cadec28-Jun-06 4:47
VK-Cadec28-Jun-06 4:47 
QuestionDate Question Pin
No-e28-Jun-06 4:21
No-e28-Jun-06 4:21 
AnswerRe: Date Question Pin
Robert Rohde28-Jun-06 5:38
Robert Rohde28-Jun-06 5:38 
GeneralRe: Date Question Pin
No-e28-Jun-06 7:19
No-e28-Jun-06 7:19 
QuestionCrystal Report [modified] Pin
militiaware28-Jun-06 2:10
militiaware28-Jun-06 2:10 
AnswerRe: Crystal Report [modified] Pin
Jats_4ru28-Jun-06 3:35
Jats_4ru28-Jun-06 3:35 
GeneralRe: Crystal Report Pin
militiaware28-Jun-06 3:50
militiaware28-Jun-06 3:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.