C# 如何动态申明变量 和 PROPERTYGRID控件如何动态给属性赋值 (谢谢)
private static ReporterGrid reporterGridA2 = new ReporterGrid();
private static ReporterGrid reporterGridA3 = new ReporterGrid();
private static ReporterGrid reporterGridA4 = new ReporterGrid();
private static ReporterGrid reporterGridA5 = new ReporterGrid();
private static ReporterGrid reporterGridA6 = new ReporterGrid();
private static ReporterGrid reporterGridA7 = new ReporterGrid();
private static ReporterGrid reporterGridA8 = new ReporterGrid();
private static ReporterGrid reporterGridA9 = new ReporterGrid();
private static ReporterGrid reporterGridA10 = new ReporterGrid();
private static ReporterGrid reporterGridA11 = new ReporterGrid();
private static ReporterGrid reporterGridA12 = new ReporterGrid();
private static ReporterGrid reporterGridA13 = new ReporterGrid();
private static ReporterGrid reporterGridA14 = new ReporterGrid();
private static ReporterGrid reporterGridA15 = new ReporterGrid();
private static ReporterGrid reporterGridA16 = new ReporterGrid();
private ReporterGrid[] _Members1 = new ReporterGrid[] { reporterGridA1, reporterGridA2, reporterGridA3, reporterGridA4, reporterGridA5, reporterGridA6, reporterGridA7, reporterGridA8, reporterGridA9, reporterGridA10, reporterGridA11, reporterGridA12, reporterGridA13, reporterGridA14, reporterGridA15, reporterGridA16 };
正如大家所看到的,这个代码实在是太垃圾了.比如有一个ArrayList arrayList = new ArrayList();arrayList有16个元素,如何根据这个arrayList的容量大小来动态申明上面的16个ReporterGrid,并且放入_Members1数组内.
2. [Category("属性配置(主要原料成本表.其他原料成本表.经营业务利润明细表)"), DisplayName("主要原料成本预算表")]
正入大家所看到的,这里的Category, 和 DisplayName属性都是写死的,琢磨了一段时间也不知道怎么把这些弄成变量的形式.请各位专家给予指导
3. [Category("属性配置(主要产品产销表.其他产品产销表.主营业务成本明细表)"), DisplayName("PCP,一、精炼石油产品")]
public ReporterGrid[] Members1
{
get
{
return _Members1;
}
set
{
_Members1 = value;
}
}
[Category("属性配置(主要产品产销表.其他产品产销表.主营业务成本明细表)"), DisplayName("CET,二、化工原料类小计")]
public ReporterGrid[] Members2
{
get
{
return _Members2;
}
set
{
_Members2 = value;
}
}
如上所表示,这是两个PROPERTYGRID的数据集,_Members1的申明为第一个问题上面的申明所表示,_Members2为另一大堆同样的申明,但其实这两个我是可以合并成一个的,如何可以做到呢.谢谢
相关推荐
给propertyGrid动态添加属性
给propertyGrid动态添加属性,估计有人想用。
C#中动态加载PropertyGrid自定义属性的策略
NET框架中的PropertyGrid控件是一个功能强大的工具,它可以以属性表的形式展示对象的属性,并允许用户编辑这些属性。这种控件广泛应用于各种应用程序的开发过程中,特别是在需要动态显示和编辑对象属性的场景中。PropertyGrid控件的核心价值在于其高度的可定制性和灵活性。开发者可以根据需要,通过编程方式控制属性的显示、编辑以及验证等各个方面。例如,可以通过自定义属性描述符来改变属性的显示名称、类型转换器、编辑器等,从而提供更为丰富和友好的用户界面。
C#动态设定PropertyGrid属性源码实战项目
为了统一管理动态描述符的创建,推荐采用工厂模式:并通过 DI 容器注入配置规则,实现解耦与可测试性。综上所述,动态属性绑定机制的实现依赖于对 .NET 类型系统的深刻理解与合理运用。通过组合反射、描述符体系与事件通知,可构建出强大且灵活的运行时属性管理系统,为复杂桌面应用提供坚实支撑。在现代桌面应用程序开发中,尤其是基于 Windows Forms 或 WPF 的配置驱动型界面系统里,控件被广泛用于可视化地展示和编辑对象的属性。
C# PropertyGrid 动态属性变更技巧与实践
本文还有配套的精品资源,点击获取 简介:在C#开发中,PropertyGrid 控件提供了一个用于在运行时查看和编辑对象属性的便捷方式。本文章深入分析了如何利用关键知识点实现运行时对 PropertyGrid 属性项的动态变更,包括对象属性的创建、分类、自定义类型转换和编辑器、动态添加/删除属性、隐藏和禁用属性以及自定义属性显示。文章可能包含了一个示例项目,演示了这些功能的...
C# PropertyGrid控件的分成 多层 折叠 和绑定自定义控件
自己编写的 主要想自己留着备份的 带有绑定控件 分层 类目。亲们喜欢也可以下载参考参考


