【问题标题】:RowSizingAutoMaxLines one row Ultragrid InfragisticsRowSizingAutoMaxLines 一行 Ultragrid Infragistics
【发布时间】:2016-12-29 19:36:53
【问题描述】:

我正在使用这段代码,这是一个不好的例子,但它可以测试,但它最终会改变所有行。

我只需要更改选定的行。

if (e.Cell.Column.Layout.Override.RowSizingAutoMaxLines == 4)
{
       e.Cell.Column.Layout.Override.RowSelectorStyle = Infragistics.Win.HeaderStyle.XPThemed;
       e.Cell.Column.Layout.Override.RowSizingAutoMaxLines = 20;
}
else
{
       e.Cell.Column.Layout.Override.RowSelectorStyle = Infragistics.Win.HeaderStyle.Default;
       e.Cell.Column.Layout.Override.RowSizingAutoMaxLines = 4;
 }

【问题讨论】:

    标签: c# resize row infragistics ultrawingrid


    【解决方案1】:

    在 Override 上设置 RowSizingAutoMaxLines 会将其设置为所有行。您可以做的是计算必要的行高并将其设置为当前行,假设您事先将RowSizing 设置为 Free 或 AutoFree。您可以使用 Graphics MeasureString 计算一行的高度,然后像这样设置每一行的高度:

    首先设置网格:

        private void UltraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e)
    {
        //  I think you need row selectors as you set their style
        e.Layout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.True;
    
        //  Set the RowSizing to some Free value to allow each row to has its onw height
        e.Layout.Override.RowSizing = RowSizing.AutoFree;
    
        //  I think you have multiline text in the cells, so you should set CellMultiLine to true too
        e.Layout.Override.CellMultiLine = Infragistics.Win.DefaultableBoolean.True;
    }
    

    然后测量一行并设置行高:

    //  Calculate the height of one line of text
    var oneLineHeight = float.MinValue;
    using(Graphics g = this.ultraGrid1.CreateGraphics())
    {
        oneLineHeight = g.MeasureString("Jj", this.ultraGrid1.Font, int.MaxValue, StringFormat.GenericTypographic).Height;
    
    }
    
    // Set the row selectors' style and the row's height
    if(e.Cell.Column.Layout.Override.RowSelectorStyle == Infragistics.Win.HeaderStyle.Default)
    {
        e.Cell.Column.Layout.Override.RowSelectorStyle = Infragistics.Win.HeaderStyle.XPThemed;
    
        //  Add 4 to add some padding
        e.Cell.Row.Height = (int)(oneLineHeight * 20 + 4);
    }
    else
    {
        e.Cell.Column.Layout.Override.RowSelectorStyle = Infragistics.Win.HeaderStyle.Default;
    
        //  Add 4 to add some padding
        e.Cell.Row.Height = (int)(oneLineHeight * 4 + 4);
    }
    

    【讨论】:

    • 有没有办法仅将这些属性应用于选定的行。其中UltraGrid1_InitializeLayout 事件代码适用于整个超网格。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多