Re: Shapes at Runtime?



In an event handler Sender is always the object which has initiated and
called the event handler.

For IDE placed components Label1Click is allocated to Label1 as the
method called when you click the label. Hence Sender is always Label1.
If you had allocated Label1Click as the OnClick event handler of
something else then other objects could be Sender.

In your Label1Click method the Sender can NEVER be a TShape.

What happened to TManyShapes and all the advice we gave as to how to
make them work. And the advice of not to use "if ... is" AND "as" in
the same statement block.

Are we wasting our time <g>.

Alan Lloyd

.



Relevant Pages

  • Re: How to pass more than two parameters in the event handler
    ... // Create EventArgs subclass to pass in 2D array parameter ... public intcurveArray; ... public delegate void getCurveButtonHandler(object sender, int ... my event handler getCurveButtonHandler but seems like this is not the best ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Directred Event Multicasting
    ... >> It would be way cool if it were possible for, say, a single event handler ... >> trap the Clicked events for all buttons and, then, re-route those events ... > (which it would normally do with the "sender" argument), ... nice to have, in addition to the (sender, eventArgs) semantics, something ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: autosave problems
    ... in the event handler ... Private void Sheet1_Buttonclick(object sender, System.EventArgs e) ... Alvin Bruney ... Could you please give me a hint on which tag property you ar talking ...
    (microsoft.public.vsnet.vstools.office)
  • RE: Tab Stops in DataGrid
    ... In the event handler, move the CurrentCell to the next cell in the grid. ... private void Form1_Load(object sender, System.EventArgs e) ... before sending mail. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: mucking with Event Definitions to get tighter coupling to Objects ?
    ... Sender, EventArgs parameter order structure. ... One exception is if the event is declared in a base class, then of course you could have a single event handler method handle the same event for multiple derived classes. ... That said, there are other clues in the method signature (for example, if the first parameter is always named "sender" and the second parameter's type always has the phrase "EventArgs" in it, then that's at least as powerful a clue). ... I'm sure that at least once I've written an event that doesn't share _any_ of the .NET convention. ...
    (microsoft.public.dotnet.languages.csharp)