开发者

How can i change the background color of datagridview headercell in code using C#?

I want to change the backcolor of a headercell in datagridview row .So how can I do that in code C#?

Also, how do I change font properties of the text named as v开发者_如何学Pythonalue of the headercell like headercell.value?


You can do this in the properties window. Set EnableHeadersVisualStyles to false then make the changes to the font, cell color, alignment, etc in ColumnHeadersDefaultCellStyle.


To change the font properties of a specified header cell you can try:

dataGridView1.Columns[index].HeaderCell.Style.Font = new Font("Arial", 24, , FontStyle.Bold);


you can try this

dataGridView1.EnableHeadersVisualStyles = false;
dataGridView1.Columns[index].HeaderCell.Style.Font = new Font("Arial", 24, , FontStyle.Bold);


I've figured out how to change the backcolor using:

dataGridView1.Rows[index].HeaderCell.Style.BackColor = System.Drawing.Color.Red;

I still don't know the answer to my second question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜