各位,我现在有一个Button,Button绑定到PropertyGrid上
例如:
Button btn = new Button();
PropertyGrid.SelectObject = btn;这样PropertyGrid便会显示这个btn的所有Property,现在我不想让ProperytGrid显示所有的Property,只让PropertyGrid显示只定的Property,例如,我只让PropertyGrid显示btn的Text,Name两个属性。
这怎样做到?
例如:
Button btn = new Button();
PropertyGrid.SelectObject = btn;这样PropertyGrid便会显示这个btn的所有Property,现在我不想让ProperytGrid显示所有的Property,只让PropertyGrid显示只定的Property,例如,我只让PropertyGrid显示btn的Text,Name两个属性。
这怎样做到?
解决方案 »
- C# .net Repeater里的控件后台调用
- winfrom 将bmp转换为bmp格式的单色图 位深度为1
- DataGridView日期后面还加了一段乱码?
- .net cf 在 wm6.1上的表现~~
- “BLL.School.PraxisInfro”不可访问,因为它受保护级别限制 (怎么回事呀)
- 有没有人用过Office Viewer OCX啊?
- 今天生日晚上在单位加班,散分庆祝....
- 一个简单的oracle问题:
- ****关于BLOB字段类型的读取****
- C Sharp Devloper's NetWork = CSDN
- C# 如何给 WORD 文件中的 formfield 付值?
- 关于文件编码的问题.
我只知道设计时使用Designer来实现的!
或者通过反射在btn的Property上添加[BrowerAble(false)],是否可以实现?
{
public string Property1
{
get
{
return string.Empty;
}
} [UserBrowerAble()]
public string Property2
{
get
{
return Guid.Empty.ToString();
}
}
} class UserBrowerAbleAttribute : System.Attribute
{
} AttributeCollection ac = new AttributeCollection(new UserBrowerAbleAttribute());
this.propertyGrid1.BrowsableAttributes = ac;Broweable等属性仍有效
PropertyGrid.SelectObject = btn;
这样自样加?怎样把[UserBrowAble()]添加到text和name上?
我找到了!
if(company.PropertyCommands.Contains("Address"))
{
company.PropertyCommands["Address"].ReadOnly=!company.PropertyCommands["Address"].ReadOnly;
}
else
{
company.PropertyCommands.Add(new CustomControls.HelperClasses.PropertyCommand("Address", true, true));
}
pg.Refresh();
public class MyButton : System.Windows.Forms.Button{}class ButtonFilterPropertiesDesigner : System.Windows.Forms.Design.ControlDesigner{
//去掉不想显示的属性
protected override void PreFilterProperties(System.Collections.IDictionary properties) {
properties.Remove("AccessibilityObject");
properties.Remove("AccessibleDefaultActionDescription");
properties.Remove("AccessibleDescription");
//去掉不想显示的事件
protected override void PreFilterEvents(System.Collections.IDictionary events) {
events.Remove("AutoSizeChanged");
events.Remove("BackColorChanged");
events.Remove("BackgroundImageChanged");
}
}