0

我有看起来像这样的对象:

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 中构建了信息,其中 Output 是:

public class ComponentPropertyList: BindingList<ComponentProperty>
{

}

设想:

组件属性列表绑定到 aInfragistics 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布局不正确,将网格指定为ComponentPropertiesClass 和 Specified后有很多 Banding对其Column Size没有任何影响。以前,我使用数据表作为需要替换为对象数据源的数据源。是否需要任何设置才能使用对象数据源。

如果我有 3 级层次结构,则失去乐队显示,而不仅仅是 3 个乐队

4

1 回答 1

3

我从 Infragisticsfourm 那里得到了一些解决方案,这些解决方案可以解决布局问题。正如我在使用时检查的那样,在表单加载事件中设置MaxBandDepth 属性IList后,这些设置可以正常工作。

// 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;

发生的问题与以下线程中的问题类似:
当数据源为 IList 时,Wingrid 的第一列扩展太大

默认情况下,网格会同步每个波段的列宽。因此,在这种情况下,您有一个递归数据源,基本上有无限数量的波段,并且对于每个波段,网格都会缩进一点。这意味着第一列变得非常大,以适应整个层次结构的缩进。默认情况下,网格将您限制为 100 个深度带,但这仍然意味着 100 级缩进。

所以有很多方法可以处理这个问题。

将网格上的 MaxBandDepth 设置为较小的值。我推荐一个介于 5 到 8 之间的值。这将在一台体面的机器上为您提供相当不错的性能,并且大多数用户可能不会钻取超过 5 个级别,无论如何。您可以将 AllowColSizing 设置为 Free。这将阻止网格同步列宽,并允许每个波段的列独立调整大小。

参考:
数据源设置后 MaxBandDepth 更改 设置数据
源时不使用
MaxBandDepth Ultragrid Hierarchical DataSource with Multiple Level Paths
UltraGrid 层次结构

于 2013-07-09T08:02:31.997 回答