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

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

DataGridView.Font プロパティ

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

DataGridView によって表示されるテキストフォント取得または設定します

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

解説解説

Font プロパティアンビエント プロパティです。アンビエント プロパティは、コントロール プロパティです。設定しない場合は、親コントロールか取得されます。たとえば、Button は、既定では親の Form と同じ BackColor持ちますアンビエント プロパティ詳細については、AmbientProperties クラスまたは Control クラス概要参照してください

Font変更不可で、プロパティをまったく調整できないため、Font プロパティには新しFont オブジェクト割り当てのみが可能です。ただし、既存フォントベースにして新しフォント設定できます

DataGridView コントロールは、DefaultCellStyle、ColumnHeadersDefaultCellStyle、および RowHeadersDefaultCellStyle の各プロパティによって返される DataGridViewCellStyle オブジェクトFont プロパティ既定値として、Font プロパティの値を使用しますFont 値を変更すると、DefaultCellStyleColumnHeadersDefaultCellStyle、および RowHeadersDefaultCellStyle の各プロパティ自動的に更新され、値を継承するすべてのセルフォント変更されます。ヘッダー セル既定で値をオーバーライドするため、特定の行、列、およびセルの値をオーバーライドできますセル スタイル継承詳細については、「Windows フォーム DataGridView コントロールでのセルスタイル」を参照してください

使用例使用例

このプロパティ使用方法を示すコード例次に示します次の例は「方法 : 連結されていない Windows フォーム DataGridView コントロール作成する」で取り上げている例の一部です。

Private Sub SetupDataGridView()

    Me.Controls.Add(songsDataGridView)

    songsDataGridView.ColumnCount = 5
    With songsDataGridView.ColumnHeadersDefaultCellStyle
        .BackColor = Color.Navy
        .ForeColor = Color.White
        .Font = New Font(songsDataGridView.Font, FontStyle.Bold)
    End With

    With songsDataGridView
        .Name = "songsDataGridView"
        .Location = New Point(8, 8)
        .Size = New Size(500, 250)
        .AutoSizeRowsMode = _
            DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders
        .ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single
        .CellBorderStyle = DataGridViewCellBorderStyle.Single
        .GridColor = Color.Black
        .RowHeadersVisible = False

        .Columns(0).Name = "Release Date"
        .Columns(1).Name = "Track"
        .Columns(2).Name = "Title"
        .Columns(3).Name = "Artist"
        .Columns(4).Name = "Album"
        .Columns(4).DefaultCellStyle.Font = _
            New Font(Me.songsDataGridView.DefaultCellStyle.Font,
 FontStyle.Italic)

        .SelectionMode = DataGridViewSelectionMode.FullRowSelect
        .MultiSelect = False
        .Dock = DockStyle.Fill
    End With

End Sub
private void SetupDataGridView()
{
    this.Controls.Add(songsDataGridView);

    songsDataGridView.ColumnCount = 5;

    songsDataGridView.ColumnHeadersDefaultCellStyle.BackColor = Color.Navy;
    songsDataGridView.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
    songsDataGridView.ColumnHeadersDefaultCellStyle.Font =
        new Font(songsDataGridView.Font, FontStyle.Bold);

    songsDataGridView.Name = "songsDataGridView";
    songsDataGridView.Location = new Point(8, 8);
    songsDataGridView.Size = new Size(500, 250);
    songsDataGridView.AutoSizeRowsMode =
        DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
    songsDataGridView.ColumnHeadersBorderStyle =
        DataGridViewHeaderBorderStyle.Single;
    songsDataGridView.CellBorderStyle = DataGridViewCellBorderStyle.Single;
    songsDataGridView.GridColor = Color.Black;
    songsDataGridView.RowHeadersVisible = false;

    songsDataGridView.Columns[0].Name = "Release Date";
    songsDataGridView.Columns[1].Name = "Track";
    songsDataGridView.Columns[2].Name = "Title";
    songsDataGridView.Columns[3].Name = "Artist";
    songsDataGridView.Columns[4].Name = "Album";
    songsDataGridView.Columns[4].DefaultCellStyle.Font =
        new Font(songsDataGridView.DefaultCellStyle.Font, FontStyle.Italic);

    songsDataGridView.SelectionMode =
        DataGridViewSelectionMode.FullRowSelect;
    songsDataGridView.MultiSelect = false;
    songsDataGridView.Dock = DockStyle.Fill;

    songsDataGridView.CellFormatting += new
        DataGridViewCellFormattingEventHandler(
        songsDataGridView_CellFormatting);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridView クラス
DataGridView メンバ
System.Windows.Forms 名前空間
DataGridView.DefaultCellStyle プロパティ
DataGridView.ColumnHeadersDefaultCellStyle プロパティ
RowHeadersDefaultCellStyle
DataGridViewCellStyle
Font
Font
その他の技術情報
Windows フォーム DataGridView コントロールでのセルスタイル
DataGridView コントロール (Windows フォーム)


このページでは「.NET Framework クラス ライブラリ リファレンス」からDataGridView.Font プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDataGridView.Font プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDataGridView.Font プロパティ を検索

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

辞書ショートカット

すべての辞書の索引

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

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

   

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



DataGridView.Font プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS