2014-12-13 121 views
-1

如何在C#中的Windows窗體中更改數據網格視圖的標題字體?或者我怎樣才能改變c#中的Windows窗體中的dataGridView列名字體? 任何幫助,將不勝感激。Datagridview標題字體在c中的窗體形式#

+0

這是Windows窗體的權利? – MajkeloDev 2014-12-13 08:34:26

+0

是的。它是Windows窗體。 – hamed 2014-12-13 08:35:53

+0

在2秒內搜索到了這個...真的,爲什麼還要問這樣的問題呢?它需要花費更多的時間來寫這個問題,然後再做一些研究。 – t3chb0t 2014-12-13 09:04:10

回答

1

讓我們假設你有一些列和您想要改變第一列的標題

MyDataGridView.Columns[0].HeaderText = "My title"; 

要更改h中的字體eader檢查此:

// ("Arial", 20") means it will use Arial font with 20em size. 
dgv.ColumnHeadersDefaultCellStyle.Font = new Font("Arial", 20); 
+0

我想更改整個datagridview的標題的字體 – hamed 2014-12-13 08:40:14

+0

您還詢問了有關列名的問題。如果你想改變標題字體我很確定你需要遍歷第一行中的所有單元格並更改其字體屬性 – MajkeloDev 2014-12-13 08:41:41

+0

我該怎麼做? – hamed 2014-12-13 08:43:48

0

How to: Set Font and Color Styles in the Windows Forms DataGridView Control

存在Column對象HeaderText屬性,

public Form1() 
{ 
    InitializeComponent(); 
    grid.DefaultCellStyle.Font = new Font("Tahoma", 15); 
    grid.Columns[0].HeaderText = "First Column"; 
    //.............. 
} 

DataGridViewColumn.Name Property

+0

我可以在哪裏聲明特定的字體? – hamed 2014-12-13 08:38:12

+0

@hamed我更新了我的答案,希望它能幫助你! – 2014-12-13 08:47:01

+0

您的答案不包含ColumnHeadersDefaultCellStyle。 OP詢問字體的頭部不是整個DataGridView – MajkeloDev 2014-12-13 08:52:08