DataGridView.Font プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

コントロールによって表示されるテキストに適用される Font。既定値は DefaultFont プロパティの値です。

Font プロパティがアンビエント プロパティです。アンビエント プロパティは、コントロール プロパティです。設定しない場合は、親コントロールから取得されます。たとえば、Button は、既定では親の Form と同じ BackColor を持ちます。アンビエント プロパティの詳細については、AmbientProperties クラスまたは Control クラスの概要を参照してください。
Font は変更不可で、プロパティをまったく調整できないため、Font プロパティには新しい Font オブジェクトの割り当てのみが可能です。ただし、既存のフォントをベースにして新しいフォントを設定できます。
DataGridView コントロールは、DefaultCellStyle、ColumnHeadersDefaultCellStyle、および RowHeadersDefaultCellStyle の各プロパティによって返される DataGridViewCellStyle オブジェクトの Font プロパティの既定値として、Font プロパティの値を使用します。Font 値を変更すると、DefaultCellStyle、ColumnHeadersDefaultCellStyle、および 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); }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDataGridView.Font プロパティを検索する場合は、下記のリンクをクリックしてください。

- DataGridView.Font プロパティのページへのリンク