2016-12-28 14 views
0

私はこのコードを使用していますが、これは悪い例ですが、テストすることはできますが、すべての行が変更されてしまいます。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; 
} 

答えて

1

オーバーライドでRowSizingAutoMaxLinesを設定すると、すべての行に設定されます。代わりにRowSizingをFreeまたはAutoFreeに設定したと仮定して、必要な行の高さを計算して現在の行に設定します。そして、1行を測定し、行の高さに設定

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

まずセットアップグリッド:あなたは1行の高さを計算し、このように各行の高さを設定するグラフィックスMeasureStringを使用することができます

// 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); 
} 
+0

ありがとう@wnvko、これは問題を回避する良い方法です。 –

関連する問題