Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP NODEFAULT equivalent in C#?
Message
From
19/04/2003 17:59:54
 
General information
Forum:
ASP.NET
Category:
Migration
Miscellaneous
Thread ID:
00765703
Message ID:
00779537
Views:
18
Nelson,

You *can* handle a KeyPress event in a sub-class of a TextBox:
// In the sub-class's Contstructor:
this.KeyPress += new KeyPressEventHandler(this.KeyPressHandler);

// and then the Handler:
protected virtual void KeyPressHandler(object sender, System.Windows.Forms.KeyEventArgs e)
{
  if (e.KeyCode == Keys.PageDown)
  {
    // or whatever it is you're checking for, handle it here and then include this:
    e.Handled = true;
  }
}
For KeyPresses that you don't handle, e.Handled will not be true and C# will process the KeyPress as normal.


~~Bonnie

>Hi Palem,
>
>Thanks for your last reply it helped me solve the problem I had back then. But now I seem to have a similar problem.
>
>The problem is that in VFP all Events seem to have an associated method linked to them, in C# this doesn't seem to be the case, that's the reason why the behavior for Events such as KeyPress from the class System.Windows.Forms.TextBox cannot be overriden by simply subclassing the TextBox Control.
>
>The bottom question is: How can I control when to execute/not execute the base class behavior for an Event of a control class that has been subclassed from the .NET FrameWork Classes (e.g. TextBoxes)?
>
>Thanks in advance.
>
>
>
>
>>> Through "base" keyword in C# you can call base implementation of the overriden method (as this does DODEFAULT() in VFP). If you do not use "base.method_name" in your method called "method_name", this is equivalent to use NODEFAULT() in VFP.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform