C
Chris Dunaway
I have created a simple Extender Provider and when I drop it onto a
form, it appears in the component tray, but none of the controls it is
supposed to provide a property for show the property in the
PropertyGrid!
Here is the class. The GlassButton is a custom button control that
derives from button and I just do some custom painting. I am sure I
have just omitted something simple, but I cannot see it.
I am using VS 2005.
//This code from BeepProvider.cs
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing.Design;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
[ProvideProperty("BeepWhenClicked", typeof(GlassButton))]
public partial class BeepProvider : Component, IExtenderProvider
{
Dictionary<GlassButton, bool> _beeps;
public BeepProvider()
{
InitializeComponent();
_beeps = new Dictionary<GlassButton, bool>();
}
public BeepProvider(IContainer container)
: this()
{
container.Add(this);
}
bool IExtenderProvider.CanExtend(object extendee)
{
if ((extendee is GlassButton) && !(extendee is BeepProvider))
return true;
else
return false;
}
public bool GetBeepWhenClicked(GlassButton gb)
{
return _beeps[gb];
} //end method GetBeedWhenClicked
public void SetBeepWhenClicked(GlassButton gb, bool value)
{
_beeps[gb] = value;
if (value)
gb.Click += new EventHandler(OnClick);
else
gb.Click -= new EventHandler(OnClick);
}
private void OnClick(object sender, EventArgs e)
{
System.Console.Beep(1000, 50);
}
}
//This code from BeepProvider.Designer.cs
using System.ComponentModel;
using System.Windows.Forms;
[ProvideProperty("BeepProvider", typeof(GlassButton))]
partial class BeepProvider
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
form, it appears in the component tray, but none of the controls it is
supposed to provide a property for show the property in the
PropertyGrid!
Here is the class. The GlassButton is a custom button control that
derives from button and I just do some custom painting. I am sure I
have just omitted something simple, but I cannot see it.
I am using VS 2005.
//This code from BeepProvider.cs
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing.Design;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
[ProvideProperty("BeepWhenClicked", typeof(GlassButton))]
public partial class BeepProvider : Component, IExtenderProvider
{
Dictionary<GlassButton, bool> _beeps;
public BeepProvider()
{
InitializeComponent();
_beeps = new Dictionary<GlassButton, bool>();
}
public BeepProvider(IContainer container)
: this()
{
container.Add(this);
}
bool IExtenderProvider.CanExtend(object extendee)
{
if ((extendee is GlassButton) && !(extendee is BeepProvider))
return true;
else
return false;
}
public bool GetBeepWhenClicked(GlassButton gb)
{
return _beeps[gb];
} //end method GetBeedWhenClicked
public void SetBeepWhenClicked(GlassButton gb, bool value)
{
_beeps[gb] = value;
if (value)
gb.Click += new EventHandler(OnClick);
else
gb.Click -= new EventHandler(OnClick);
}
private void OnClick(object sender, EventArgs e)
{
System.Console.Beep(1000, 50);
}
}
//This code from BeepProvider.Designer.cs
using System.ComponentModel;
using System.Windows.Forms;
[ProvideProperty("BeepProvider", typeof(GlassButton))]
partial class BeepProvider
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}