l33*_*33t 6 .net c# propertygrid typeconverter
我有一个System.Windows.Forms.PropertyGrid不同类型的价值观.对于特定项目,我想显示可供选择的有用值列表.用户还可以键入新值.类似于传统下拉组合框的东西:

到目前为止,我有自己的System.ComponentModel.TypeConverter,但我无法弄清楚如何获得建议值的下拉列表和直接编辑值的可能性.请帮忙!
您可以通过实现自己的UITypeEditor来实现此目的.
我建议阅读" 充分利用.NET Framework PropertyGrid控件".特别是,标题为为您的属性提供自定义UI的部分介绍了如何为特定属性进行自定义控件.
小智 6
这很容易.在你自己的StringConverter回报false的GetStandardValuesExclusive,就是这样.
看这里:
internal class cmbKutoviNagiba : StringConverter
{
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{
return FALSE; // <----- just highlight! remember to write it lowecase
}
public override TypeConverter.StandardValuesCollection GetStandardValues(
ITypeDescriptorContext context)
{
string[] a = { "0", "15", "30", "45", "60", "75", "90" };
return new StandardValuesCollection(a);
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
我FALSE用大写字母写了,只是为了让你更容易看到它.请用小写字母:)
| 归档时间: |
|
| 查看次数: |
2668 次 |
| 最近记录: |