Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Issue resolving Sender and e

$
0
0

I've got an MDI parent window (archaic technology, I know, but I still gotta support it) whose menu has to be able to respond to changes made on child forms.  Controls which have selected text, for instance, notify the Edit menu items in order to toggle the menus' Enabled settings.  I'm attempting to simplify the code by creating Edit functions in the MDI window, and having each control pass Sender and EventArgs parameters to those functions. 

The problem is that even though I have Object Sender and EventArgs e in my definition for these methods, the parameter names do not resolve in the function body.  Inside a Try block, any mention of these results in a compiler warning (and of course the code won't compile) of the form "Type or namespace 'Sender' could not be found."  Above the Try block, just within the function body, the names do resolve, but only until I involve them in an expression such as "var t = typeof(Sender)".

I'm using Visual Studio 2010 SP1.  Is this a known issue with VS, or am I doing something wrong?  Is there any reason why these parameter / names would be valid in an event handler, but not in a function called by the event handler (passing the parameters through to it)?

 

Viewing all articles
Browse latest Browse all 31927

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>