Reputation: 644
I have a Component like this:
public partial class FontScalingManager : Component
{
...other stuff...
/// <summary>
/// List of Controls, which get their Font scaled
/// </summary>
[ListBindable(BindableSupport.Yes),
Description("List of Controls, which get their Font scaled")]
public List<Control> ScalingControls
{
get { return _scalingControls; }
}
}
So, after dropping this Component on a Form, I want to fill this list in the designer. I would prefer doing this manually in the designer with a UITypeEditor or something, by selecting, some of the Controls in the Form.
As is, the designer automatically gives me an editor to add new Controls to this list, so how do I manage to tell it, that I want to choose from all existing Controls?
Can I set something for that editor, or do I need a custom one?
Every help is appreciated.
Upvotes: 1
Views: 1645
Reputation: 112702
Controls have a Tag
property. Set the Tag to "scaling" for the scaling controls. Then determine the scaling controls when accessing them for the first time:
private List<Control> _scalingControls;
public List<Control> ScalingControls
{
get
{
if (_scalingControls == null) {
_scalingControls = new List<Control>();
foreach (Control c in frm.Controls) {
if ((string)c.Tag == "scaling") {
_scalingControls.Add(c);
}
}
}
return _scalingControls;
}
}
Upvotes: 0
Reputation: 942247
The IExtenderProvider interface was made to do this. The .NET HelpProvider component was implemented that way. Note how it adds properties to other controls on the same form. Use the example in the MSDN Library article for it to get basic guidance on how to implement it properly.
Upvotes: 2