[#显示分层数据的 UltraWinGrid 与一些自定义网格的外观设置吗?
来源:互联网 发布:相片水印软件 编辑:程序博客网 时间:2024/06/05 17:29
本文来自:http://www.itstrike.cn/Question/276f4eda-89bc-4155-921e-bcc591332d9c.html
我有对象,看起来像这样:
public class ComponentProperty{ public string Property { get; set; } public object Value { get; set; } public string DataType { get; set; } public string PropertyKey { get; set; } public string Unit { get; set; } public string DependencyType { get; set; } public object ListType { get; set; } public List<ComponentProperty> Properties { get; set; }}
我过去的信息生成以下形式的 BindingList 输出在哪里:
public class ComponentPropertyList: BindingList<ComponentProperty>{}
方案:
列表中的组件属性绑定到 Infragistics Ultra WinGrid 来生成大师-详细信息视图和我做了之后中网格设置的自定义:
void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e){ ultraGrid1.DisplayLayout.Override.AllowColSizing = AllowColSizing.Synchronized; e.Layout.Bands[0].Override.HeaderAppearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True; ultraGrid1.DisplayLayout.Appearance.BackColor = Color.White; ultraGrid1.DisplayLayout.Appearance.BackColor2 = Color.White; ultraGrid1.DisplayLayout.Override.ActiveRowAppearance = null; ultraGrid1.DisplayLayout.BorderStyle = UIElementBorderStyle.None; ultraGrid1.DisplayLayout.Override.BorderStyleCell = UIElementBorderStyle.None; ultraGrid1.DisplayLayout.Override.BorderStyleRow = UIElementBorderStyle.None; ultraGrid1.DisplayLayout.Override.ColumnAutoSizeMode = ColumnAutoSizeMode.Default; ultraGrid1.DisplayLayout.Bands[0].ColHeadersVisible = true; ultraGrid1.DisplayLayout.Bands[0].Override.RowSelectors = DefaultableBoolean.False; ultraGrid1.DisplayLayout.Bands[0].Columns[0].CellActivation = Activation.NoEdit; ultraGrid1.DisplayLayout.Bands[0].Columns[1].CellActivation = Activation.AllowEdit; //Infosys: Nikita - Added for #1143 - START ultraGrid1.DisplayLayout.Bands[0].Columns["Unit"].CellActivation = Activation.NoEdit; //Infosys: Nikita - Added for #1143 - END ultraGrid1.DisplayLayout.Bands[0].Columns[1].CellAppearance.BorderColor = Color.Black; ultraGrid1.DisplayLayout.Override.RowAppearance.TextVAlign = VAlign.Middle; // e.Layout.Bands[0].Columns[1].Width = 90; ultraGrid1.DisplayLayout.Scrollbars = Scrollbars.Automatic; ultraGrid1.DisplayLayout.ScrollBounds = ScrollBounds.ScrollToFill; ultraGrid1.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns; ultraGrid1.DisplayLayout.Bands[0].Columns[2].AutoSizeMode = ColumnAutoSizeMode.None; ultraGrid1.DisplayLayout.Bands[0].Columns[3].AutoSizeMode = ColumnAutoSizeMode.None; ultraGrid1.DisplayLayout.Bands[0].Columns[2].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns[3].Hidden = true; //ultraGrid1.DisplayLayout.Bands[0].Columns[Constants.Collevel].Hidden = true; //ultraGrid1.DisplayLayout.Bands[0].Columns[Constants.ColID].Hidden = true; //ultraGrid1.DisplayLayout.Bands[0].Columns[Constants.Colparentid].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns["DependencyType"].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns["ListType"].Hidden = true; //ultraGrid1.DisplayLayout.Bands[0].Override.AllowColSizing = AllowColSizing.Synchronized; ultraGrid1.DisplayLayout.BorderStyle = UIElementBorderStyle.Default; //ultraGrid1.DisplayLayout.Bands[0].Columns[1].TabStop = false; ultraGrid1.DisplayLayout.Bands[0].Columns[1].CellAppearance.BackColor = Color.White; ultraGrid1.DisplayLayout.Bands[0].Columns["Value"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid1.DisplayLayout.Bands[0].Columns["Value"].ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.Always; ultraGrid1.DisplayLayout.Bands[0].Columns["Value"].CellAppearance.BackColor = Color.White; ultraGrid1.DisplayLayout.Override.SupportDataErrorInfo = SupportDataErrorInfo.CellsOnly; ultraGrid1.DisplayLayout.Bands[0].Columns[1].SupportDataErrorInfo = DefaultableBoolean.True; ultraGrid1.DisplayLayout.Bands[0].Columns[0].Width = 200; ultraGrid1.DisplayLayout.Bands[0].Columns["Value"].Width = 120; ultraGrid1.DisplayLayout.Bands[0].Columns["Value"].TabIndex = 0; ultraGrid1.DisplayLayout.Bands[0].Columns["Unit"].Width = 60; for (int rowCount = 0; rowCount < ultraGrid1.Rows.Count; rowCount++) { UltraGridRow row = ultraGrid1.Rows[rowCount]; if (string.IsNullOrEmpty(Convert.ToString(row.Cells[1].Value))) { row.Cells[1].Appearance.BackColor = Color.White; } } ultraGrid1.DisplayLayout.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid; ultraGrid1.DisplayLayout.Override.BorderStyleCell = Infragistics.Win.UIElementBorderStyle.Solid; ultraGrid1.DisplayLayout.Override.GroupByRowSpacingAfter = 0; ultraGrid1.DisplayLayout.Override.GroupByRowSpacingBefore = 0; ultraGrid1.DisplayLayout.Override.HeaderPlacement = HeaderPlacement.OncePerGroupedRowIsland; if (ultraGrid1.DisplayLayout.Bands.Count > 1) { ultraGrid1.DisplayLayout.Bands[1].ColHeadersVisible = false; ultraGrid1.DisplayLayout.Bands[1].Columns[2].AutoSizeMode = ColumnAutoSizeMode.None; ultraGrid1.DisplayLayout.Bands[1].Columns[3].AutoSizeMode = ColumnAutoSizeMode.None; ultraGrid1.DisplayLayout.Bands[1].Columns[0].CellActivation = Activation.NoEdit; ultraGrid1.DisplayLayout.Bands[1].Columns[4].CellActivation = Activation.NoEdit; ultraGrid1.DisplayLayout.Bands[1].Columns[2].Hidden = true; ultraGrid1.DisplayLayout.Bands[1].Columns[3].Hidden = true; ultraGrid1.DisplayLayout.Bands[1].Columns["DependencyType"].Hidden = true; ultraGrid1.DisplayLayout.Bands[1].Columns["ListType"].Hidden = true; ultraGrid1.DisplayLayout.Bands[1].Columns[0].Width = 120; //ultraGrid1.DisplayLayout.Bands[1].Columns[0].TabStop = false; ultraGrid1.DisplayLayout.Bands[1].Columns["Value"].Width = 180; ultraGrid1.DisplayLayout.Bands[1].Columns["Value"].TabIndex = 0; ultraGrid1.DisplayLayout.Bands[1].Columns["Unit"].Width = 60; //ultraGrid1.DisplayLayout.Bands[1].Columns[Constants.ColUnit].TabStop = false; ultraGrid1.DisplayLayout.Override.RowSelectors = DefaultableBoolean.False; if (e.Layout.Bands[1].Columns.Exists(" ") == true) { ultraGrid1.DisplayLayout.Bands[1].Columns[" "].Width = 0; } if (e.Layout.Bands[1].Columns.Exists(" ") == false) { ultraGrid1.DisplayLayout.Bands[1].Columns.Add(" "); ultraGrid1.DisplayLayout.Bands[1].Columns[" "].Header.VisiblePosition = 0; ultraGrid1.DisplayLayout.Bands[1].Columns[" "].Width = 0; } if (ultraGrid1.DisplayLayout.Bands.Count > 2) { ultraGrid1.DisplayLayout.Bands[2].ColHeadersVisible = false; ultraGrid1.DisplayLayout.Bands[2].Columns[2].AutoSizeMode = ColumnAutoSizeMode.None; ultraGrid1.DisplayLayout.Bands[2].Columns[3].AutoSizeMode = ColumnAutoSizeMode.None; ultraGrid1.DisplayLayout.Bands[2].Columns[0].CellActivation = Activation.NoEdit; ultraGrid1.DisplayLayout.Bands[2].Columns[4].CellActivation = Activation.NoEdit; //ultraGrid1.DisplayLayout.Bands[2].Override.AllowColSizing = AllowColSizing.None; ultraGrid1.DisplayLayout.Bands[2].Columns[2].Hidden = true; ultraGrid1.DisplayLayout.Bands[2].Columns[3].Hidden = true; ultraGrid1.DisplayLayout.Bands[2].Columns["DependencyType"].Hidden = true; ultraGrid1.DisplayLayout.Bands[2].Columns["ListType"].Hidden = true; ultraGrid1.DisplayLayout.Bands[2].Columns[0].Width = 200; ultraGrid1.DisplayLayout.Bands[2].Columns["Value"].Width = 120; ultraGrid1.DisplayLayout.Bands[2].Columns["Unit"].Width = 60; ultraGrid1.DisplayLayout.Override.RowSelectors = DefaultableBoolean.False; //ultraGrid1.DisplayLayout.Bands[2].Columns[0].TabStop = false; ultraGrid1.DisplayLayout.Bands[2].Columns["Value"].TabIndex = 0; //ultraGrid1.DisplayLayout.Bands[2].Columns[Constants.ColUnit].TabStop = false; ultraGrid1.DisplayLayout.Bands[2].Columns["Value"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; ultraGrid1.DisplayLayout.Bands[2].Columns["Value"].ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle. if (e.Layout.Bands[2].Columns.Exists(" ") == true) { ultraGrid1.DisplayLayout.Bands[2].Columns[" "].Width = 0; } if (e.Layout.Bands[2].Columns.Exists(" ") == false) { ultraGrid1.DisplayLayout.Bands[2].Columns.Add(" "); ultraGrid1.DisplayLayout.Bands[2].Columns[" "].Header.VisiblePosition = 0; ultraGrid1.DisplayLayout.Bands[2].Columns[" "].Width = 0; } } } e.Layout.Bands[0].Override.CellAppearance.BorderAlpha = Alpha.Transparent; e.Layout.Bands[0].Override.SelectedCellAppearance.ForeColor = Color.Black; e.Layout.Bands[0].Override.RowAppearance.BorderAlpha = Alpha.Transparent; e.Layout.Bands[0].Override.CellAppearance.BackColorAlpha = Alpha.Transparent; e.Layout.Bands[0].Columns[0].CellActivation = Activation.NoEdit; e.Layout.Bands[0].Columns[1].CellActivation = Activation.NoEdit; e.Layout.Bands[0].Columns[2].CellActivation = Activation.NoEdit; ultraGrid1.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns; ultraGrid1.DisplayLayout.Bands[0].Override.RowSelectors = DefaultableBoolean.False; ultraGrid1.DisplayLayout.Appearance.BackColor = Color.White; //ultraGrid1.DisplayLayout.Override.AllowColSizing = AllowColSizing.None; //ultraGrid1.DisplayLayout.Override.AllowRowLayoutColMoving = GridBagLayoutAllowMoving.None; ultraGrid1.DisplayLayout.BorderStyle = UIElementBorderStyle.Solid; ultraGrid1.DisplayLayout.Bands[0].Columns[1].ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.Always; ultraGrid1.DisplayLayout.TabNavigation = TabNavigation.NextCell; if (e.Layout.Bands[0].Columns.Exists(" ") == true) { ultraGrid1.DisplayLayout.Bands[0].Columns[" "].Width = 0; //ultraGrid1.DisplayLayout.Bands[0].Columns[" "].ColSpan = 3; } if (e.Layout.Bands[0].Columns.Exists(" ") == false) { ultraGrid1.DisplayLayout.Bands[0].Columns.Add(" ").DataType = typeof(bool); ultraGrid1.DisplayLayout.Bands[0].Columns[" "].Header.VisiblePosition = 0; ultraGrid1.DisplayLayout.Bands[0].Columns[" "].Width = 0; // ultraGrid1.DisplayLayout.Bands[0].Columns[" "].ColSpan = 3; ultraGrid1.DisplayLayout.Bands[0].Columns[" "].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox; UltraGridColumn checkBox = ultraGrid1.DisplayLayout.Bands[0].Columns[" "]; } foreach (UltraGridBand band in ultraGrid1.DisplayLayout.Bands) { band.HeaderVisible = false; }}
componentProperties 集合可以有 N 级别根据的值。
CompoentProperty 1
SubProperty1--->
SubSubProperty1--->
SubSubProperty1--->
CompoentProperty 2
SubProperty2--->
SubSubProperty2--->
SubSubProperty2--->
SubSubProperty3--->
SubSubProperty3--->
--------------------------->SubSubProperty NN
问题:
布局是不正确的有很多的班丁后分配 DataSource
到网格作为 ComponentProperties
类和指定Column Size
不会对它的任何影响。以前,我作为需要替换的对象数据源的数据源使用数据表。有没有任何的设置需要使用对象数据源。
解决方法 1:
我的一些解决方案从 Infragistics 位,有什么解决的布局问题。如我检查了当我使用 IList
然后这些设置工作正确设置MaxBandDepth Property在窗体加载事件之后。
// Load only upto two descendant bands. So even if the data source has more than 3 level // deep hierarchy, the UltraGrid will only make use of first two levels and ignore the // levels deeper than that. this.ultraGrid1.DisplayLayout.MaxBandDepth = 3;
发生的问题是相似的所问的下面的线程:
第一列的 Wingrid 扩展太大,当数据源是 IList
引用:默认情况下,网格同步每个波段的列宽。所以在这种情况下在你有一个递归数据源,有的乐队基本上是一个无限的数字和为每个带区网格有点缩进。这意味着第一列获取很大以容纳下来层次结构中的缩进量。网格限制你对 100 带的深度,默认情况下,但这仍然意味着 100 级别的缩进。
所以有很多种方法可以处理这。
将 MaxBandDepth 设置为一个较小的值的网格上。我建议 5 和 8 之间的一个值。这会给你一个体面的机器上很好的性能和大多数用户可能不会深入以上 5 个级别,不管怎么说的。您可以将 AllowColSizing 设置为自由。这将停止同步,列宽度从网格并允许每个带区列以独立的大小调整。
MaxBandDepth 更改后的数据源设置
设置数据源时不使用 MaxBandDepth
Ultragrid 分层数据源与多个级别的路径
UltraGrid 层次结构
- [#显示分层数据的 UltraWinGrid 与一些自定义网格的外观设置吗?
- 用于显示分层数据的嵌套网格
- 用于显示分层数据的嵌套网格(from msdn)
- 自定义UltraWinGrid控件的列合并模式
- UltraWinGrid导出EXCEL的一些技术文档
- handsontable一个Excel一样的外观数据网格组件
- gridview控件的一些外观设置
- 数据网格中显示动态的信息
- AdvancedDataGrid使用:设置分层数据的数据源
- view的分层显示
- 自定义FileDialog的外观
- 自定义外观的Button
- 自定义外观的ListView
- 自定义SeekBar的外观
- 控件的外观设置
- [Android]一些控件的外观属性设置实例
- UltraWinGrid.BeforeCellActivate事件的应用
- datagrid的数据分层
- 自定义 滑动解锁
- Hibernate学习-01:Hibernate框架的概述
- eclipse class file editor source not found
- setTimeout那些事儿
- OkHttp3.6.0+Retrofit2.2.0持久化cookie
- [#显示分层数据的 UltraWinGrid 与一些自定义网格的外观设置吗?
- 手机收不到第三方发送的短信及验证码
- 【Android 屏幕扩展/共享】5分钟搞定—电脑 与 手机共享屏幕
- 文档编写要求
- APP安全报告第六期:用户病例信息存在泄漏风险,医疗APP需加强安全措施!
- 用C语言实现将int类型转化为字符串,不使用已有的转换函数
- Java核心技术II:ZiP压缩文档
- PHP 轻量级的PHP类检测移动设备(包括平板电脑)。
- AJAX