DataGridView.RowTemplate プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataGridView.RowTemplate プロパティの意味・解説 

DataGridView.RowTemplate プロパティ

メモ : このプロパティは、.NET Framework version 2.0 で新しく追加されたものです。

コントロール内のすべての行のテンプレートを表す行を取得または設定します。

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

Public Property RowTemplate As
 DataGridViewRow
Dim instance As DataGridView
Dim value As DataGridViewRow

value = instance.RowTemplate

instance.RowTemplate = value
public DataGridViewRow RowTemplate { get; set;
 }
public:
property DataGridViewRow^ RowTemplate {
    DataGridViewRow^ get ();
    void set (DataGridViewRow^ value);
}
/** @property */
public DataGridViewRow get_RowTemplate ()

/** @property */
public void set_RowTemplate (DataGridViewRow
 value)
public function get RowTemplate
 () : DataGridViewRow

public function set RowTemplate
 (value : DataGridViewRow)

プロパティ値
行テンプレートを表す DataGridViewRow。

例外例外
例外の種類条件

InvalidOperationException

このプロパティの設定時に指定された値には、DataGridView プロパティが設定されています。

解説解説

さまざまな DataGridView セル スタイル プロパティが提供する制御よりも、DataGridView 行の外観をさらに細かく制御することが必要になる場合があります。RowTemplate プロパティを使用すると、すべての行 (AllowUserToAddRows が true の場合は新しいレコードの行を含む) でテンプレートとして使用する DataGridViewRow を作成して初期化できます。

これは、行の高さなどのプロパティに既定値を設定する場合に便利です。たとえば、複数の列にまたがる内容を表示するために、通常のセルの内容の下に空白ができるように、既定の行を高くできます。

DataGridViewRow クラスから派生したカスタム型を使用して外部データを表示する場合は、行テンプレートを設定する必要があります。バインドされていない DataGridView コントロールを使用すると、Rows コレクションに作成した行の種類のインスタンスをプログラムによって読み込むことができます。ただし、外部データを表示する場合、行は自動的に生成されますが、行テンプレートに基づいています。この行テンプレートを、作成した行の種類のインスタンスに設定できます。

最初に値を取得したときにこのプロパティが設定されていない場合は、新しい DataGridViewRow を作成して返します。

使用例使用例

行テンプレートを使用して、行の高さの初期値と最小値を指定するコード例を次に示します。

With Me.dataGridView1.RowTemplate
    .DefaultCellStyle.BackColor = Color.Bisque
    .Height = 35
    .MinimumHeight = 20
End With
DataGridViewRow row = this.dataGridView1.RowTemplate;
row.DefaultCellStyle.BackColor = Color.Bisque;
row.Height = 35;
row.MinimumHeight = 20;
DataGridViewRow^ row = this->dataGridView1->RowTemplate;
row->DefaultCellStyle->BackColor = Color::Bisque;
row->Height = 35;
row->MinimumHeight = 20;

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「DataGridView.RowTemplate プロパティ」の関連用語

DataGridView.RowTemplate プロパティのお隣キーワード
検索ランキング

   

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



DataGridView.RowTemplate プロパティのページの著作権

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

©2026 GRAS Group, Inc.RSS