DataGridViewRow.GetPreferredHeight メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataGridViewRow.GetPreferredHeight メソッドの意味・解説 

DataGridViewRow.GetPreferredHeight メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

指定した基準基づいて指定した行の適切な高さを計算します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Overridable Function
 GetPreferredHeight ( _
    rowIndex As Integer, _
    autoSizeRowMode As DataGridViewAutoSizeRowMode, _
    fixedWidth As Boolean _
) As Integer
Dim instance As DataGridViewRow
Dim rowIndex As Integer
Dim autoSizeRowMode As DataGridViewAutoSizeRowMode
Dim fixedWidth As Boolean
Dim returnValue As Integer

returnValue = instance.GetPreferredHeight(rowIndex, autoSizeRowMode, fixedWidth)
public virtual int GetPreferredHeight (
    int rowIndex,
    DataGridViewAutoSizeRowMode autoSizeRowMode,
    bool fixedWidth
)
public:
virtual int GetPreferredHeight (
    int rowIndex, 
    DataGridViewAutoSizeRowMode autoSizeRowMode, 
    bool fixedWidth
)
public int GetPreferredHeight (
    int rowIndex, 
    DataGridViewAutoSizeRowMode autoSizeRowMode, 
    boolean fixedWidth
)
public function GetPreferredHeight (
    rowIndex : int, 
    autoSizeRowMode : DataGridViewAutoSizeRowMode, 
    fixedWidth : boolean
) : int

パラメータ

rowIndex

適切な高さを計算する行のインデックス

autoSizeRowMode

自動サイズ設定モード指定する DataGridViewAutoSizeRowMode。

fixedWidth

固定セル幅に対す適切な高さを計算する場合trueそれ以外場合false

戻り値
行の適切な高さ (ピクセル単位)。

例外例外
例外種類条件

InvalidEnumArgumentException

autoSizeRowMode有効な DataGridViewAutoSizeRowMode 値ではありません。

ArgumentOutOfRangeException

rowIndex有効な範囲 (0 ~ コントロール行数 - 1) 内にありません。

解説解説

このプロパティは、DataGridView コントロールの、内容に基づく自動サイズ変更機能で、行の適切な高さを決定するために使用されます。rowIndex の値を使用して共有行の実際の行インデックス指定できます(共有行の Index プロパティ値は -1 です)。

fixedWidth パラメータ値を false にすると、セルの幅に対する高さの比率理想的となるような列幅の計算値に基づいて、行の高さを計算します

セル内容複数の行に折り返されるようにするには、セルに対して有効なセル スタイルの WrapMode プロパティ値を True設定する必要があります

自動サイズ変更詳細については、「Windows フォーム DataGridView コントロールサイズ変更オプション」を参照してください

使用例使用例

GetPreferredHeight メソッド使用してサイズ変更された行新し埋め込み決定するコード例次に示します次のコード例は、「方法 : Windows フォームの DataGridView コントロールの行の外観カスタマイズする」で示されている例の一部です。

' Adjusts the padding when the user changes the row height so that 
' the normal cell content is fully displayed and any extra
' height is used for the content that spans multiple columns.
Sub dataGridView1_RowHeightChanged(ByVal sender
 As Object, _
    ByVal e As DataGridViewRowEventArgs) _
    Handles dataGridView1.RowHeightChanged

    ' Calculate the new height of the normal cell content.
    Dim preferredNormalContentHeight As Int32
 = _
        e.Row.GetPreferredHeight(e.Row.Index, _
        DataGridViewAutoSizeRowMode.AllCellsExceptHeader, True)
 - _
        e.Row.DefaultCellStyle.Padding.Bottom()

    ' Specify a new padding.
    Dim newPadding As Padding = e.Row.DefaultCellStyle.Padding
    newPadding.Bottom = e.Row.Height - preferredNormalContentHeight
    e.Row.DefaultCellStyle.Padding = newPadding

End Sub
// Adjusts the padding when the user changes the row height so that
 
// the normal cell content is fully displayed and any extra
// height is used for the content that spans multiple columns.
void dataGridView1_RowHeightChanged(object sender,
    DataGridViewRowEventArgs e)
{
    // Calculate the new height of the normal cell content.
    Int32 preferredNormalContentHeight =
        e.Row.GetPreferredHeight(e.Row.Index, 
        DataGridViewAutoSizeRowMode.AllCellsExceptHeader, true)
 -
        e.Row.DefaultCellStyle.Padding.Bottom;

    // Specify a new padding.
    Padding newPadding = e.Row.DefaultCellStyle.Padding;
    newPadding.Bottom = e.Row.Height - preferredNormalContentHeight;
    e.Row.DefaultCellStyle.Padding = newPadding;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

DataGridViewRow.GetPreferredHeight メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataGridViewRow.GetPreferredHeight メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS