关于property grid下拉框的定制

本文详细介绍了如何通过继承UITypeEditor来扩展微软提供的PropertyGrid,提供了一个示例代码,并引用了一篇相关文章进行补充说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近在实践的过程中,发现经常需要对微软提供的property grid 定制自己的扩展。在查阅了一些文档之后,发现这种扩展还是很容易并且比较有意思的。这里主要是继承UITypeEditor来扩展。比较简单,贴一些可以用来示例的代码
public class MyUIEditor:UITypeEditor 
(
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return System.Drawing.Design.UITypeEditorEditStyle.DropDown;
}//这里有3种editstyle
public override object EditValue(ITypeDescriptorContext context,IServiceProvider provider,object value)
{
System.Windows.Forms.Design.IWindowsFormsEditorService iws=
rSystem.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService));
if(iws!=null)
{
mycontrol con = new mycontrol();//因为是自己定制的control理论上可以实现各种要求
con.setcontainer(iws);//con需要实现这个方法。
iws.DropDownControl(con);//这里需要绑定
}
return value;
}

 有一篇文章也是举例讲了这个,如果以后要用,倒是可以查阅《基于反射机制的PropertyGrid下拉框扩展方法》(电脑知识与技术)

以上都是留作学习使用 。

 

转载于:https://www.cnblogs.com/dadba/archive/2012/02/24/2367204.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值