DevExpress控件使用交流,DevExpress中国社区Dev联系电话 联系电话:023-68661681

绑定属性到DevExpress propertyGridControl上时可否只显示需要的数据

来源:本站   发布时间:2012-03-01   浏览:6375次

问题描述:我们在绑定控件属性到DevExpress propertyGridControl上时可否只显示我们需要的数据呢?我想隐藏一部分属性。

问题解答:可以的,您可以使用CustomPropertyDescriptors来过滤控件属性

关键代码:

voidpropertyGridControl1_CustomPropertyDescriptors(object sender,CustomPropertyDescriptorsEventArgs e) {

// Provide properties to be displayed at the rootlevel

if(e.Context.PropertyDescriptor == null) {

  PropertyDescriptorCollection filteredCollection = newPropertyDescriptorCollection(null);

  AddIfPropertyExist(e.Properties, filteredCollection, "Dock");

   AddIfPropertyExist(e.Properties,filteredCollection, "Size");

  AddIfPropertyExist(e.Properties, filteredCollection,"Location");

……

  e.Properties = filteredCollection;

 }

}

示例下载

本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/163.html
在线
客服
微信
QQ 电话
023-68661681
返回
顶部