Home All Groups Group Topic Archive Search About

IExtenderProvider and events (Visual Studio Automation)

Author
26 Jan 2006 1:02 AM
Anatoly
Hello everybody,

I am wondering is there a way to define extension property of the event
type? I am trying to implement validation control and want to expose an
event property that I would initialize with validation handler at design
time.

I know how to define extension property of standard type or some class
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxconautomationextenders.asp).

I also know how to expose the event property on the validation control
itself - just use BrowsableAttribute: [Browsable(true)].

But when I try to define extension property of EventHandler type it just
goes to "Properties" tab of control's Properties window, not "Events" tab
where I want it to go.

Here is what I am doing:

[ProvideProperty("ValidationHandler", typeof(Control))]
public class ValControl : System.ComponentModel.Component,
IExtenderProvider
{
...
  public bool CanExtend(object extendee)
  {
   if ((extendee is TextBox) || (extendee is ComboBox)) return true;
   return false;
  }

  public void SetValidationHandler(object inputComponent, EventHandler eh)
{ ... }

  public EventHandler GetValidationHandler(object inputComponent)  {  ...  }
...
}

Thanks,
Anatoly

AddThis Social Bookmark Button