使用验证控件作为起点(验证道具的控件在很大程度上完成了我想要的操作)我能够通过以下方式解决这个问题。
- 看看ValidateControlConverter.cs
创建了我自己的 LabelOrTextBoxTypeConverter,并用我自己的逻辑覆盖了与 ValidateControlConverter (FilterControl) 相同的方法。
class LabelOrTextBoxTypeConverter : ControlIDConverter
{
//public ControlByTypeIDConverter(List<Type> WantedControlTypes)
//{
// this.ControlTypes = WantedControlTypes;
//}
/// <summary>
///
/// </summary>
/// <param name="control"></param>
/// <returns></returns>
protected override bool FilterControl(Control control)
{
bool isWanted = false;
foreach (var atype in this.ControlTypes)
{
isWanted |= control.GetType() == atype;
}
return isWanted;
}
public List<Type> ControlTypes { get { return new List<Type>() { typeof(TextBox), typeof(Label) }; } }
}
最后一步是在控件属性上
[
Category("Target Controls")
, DefaultValue("")
, Bindable(true)
, Description("The State Text Box To Auto Fill.")
, TypeConverterAttribute(typeof(LabelOrTextBoxTypeConverter))
]
public string StateControlToAutoFill
as you can see i didn't get 100% what i wanted here.
i was hoping to set this up to just be a Control Filter class and have a list of the types of controls i was interested in passed in. I need to do a little more digging here to complete this but for the time being this is working as expected. anyone who knows the answer to this off the top of their head would be much appreciated.
All said and done this is working. Won't really get to use it to much as you have to be in design mode using the prop panel to take advantage of the generated list.