Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP NODEFAULT equivalent in C#?
Message
From
20/04/2003 11:45:01
 
General information
Forum:
ASP.NET
Category:
Migration
Miscellaneous
Thread ID:
00765703
Message ID:
00779619
Views:
22
Nelson,

I'd say the Click event is not a good example, since nothing's done normally in a Click event that you'd need to override. Unless you're talking about overriding the event in a sub-class of a sub-class. In that case, make sure that in your button's base class you define the Click handler as virtual so that it can be overridden in your sub-classes:
protected virtual Click_Handler(object sender, System.EventArgs e)
{
  // code here
}
Then, in your sub-classed Click handler, you use override:
private override Click_Handler(object sender, System.EventArgs e)
{
  // to execute the base class code, if you need it:
  base.Click_Handler(sender, e);
}
I think I got it right (this is untested code off the top of my head) ...

~~Bonnie


>Hi Bonnie,
>
>BTW is this type of functionality available for *All* events. I ask this because I have only seen the Handled property in the KeyEventArgs and KeyPressEventArgs classes.
>
>Is it possible to achive this with other events such as click, etc?
>
>Thanks in advance.
>
>
>
>>> 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 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