簡體   English   中英

RowSizingAutoMaxLines一排超網格基礎設施

[英]RowSizingAutoMaxLines one row Ultragrid Infragistics

我正在使用此代碼,這是一個不好的例子,但可以測試,但最終會更改所有行。

我只需要更改選擇的行。

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

將RowSizingAutoMaxLines設置為Override會將其設置為所有行。 相反,您可以做的是計算必要的行高並將其設置為當前行, 前提是您事先已將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);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM