开发者

How to change datagridview columnname color or style?

How to change datagridview columnname color or style?

How can I change the color or type of the column name on开发者_开发百科 a DataGridView in WinForms?


You have to set the DataGridView.EnableHeadersVisualStyle properly to false to make changes to the Style.Fore/BackColor property visible.


Click the little triangle on the top right of the DGV, click edit columns, scroll to the column you want to change, and go to town in the property grid

To change the color, you'll want the DefaultCellStyle -> Backcolor

to change the type of column, you'll want the...ColumnType property


<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="bank_id" DataSourceID="SqlDataSource1" BackColor="#CCCCFF">.....try it


dataGridView1.RowsDefaultCellStyle.SelectionBackCo lor = Color.FromArgb(98, 110, 110);
dataGridView1.RowHeadersDefaultCellStyle.BackColor = Color.Black;
dataGridView1.RowHeadersDefaultCellStyle.ForeColor = Color.White;
dataGridView1.ColumnHeadersDefaultCellStyle.BackCo lor = Color.Black;
dataGridView1.ColumnHeadersDefaultCellStyle.ForeCo lor = Color.White;
dataGridView1.AlternatingRowsDefaultCellStyle.Back Color = Color.Black;
dataGridView1.GridColor = Color.FromArgb(80, 90, 90);
dataGridView1.RowsDefaultCellStyle.BackColor = Color.FromArgb(27, 30, 30);
dataGridView1.RowsDefaultCellStyle.Padding = new Padding(5, 0, 5, 0);
dataGridView1.RowsDefaultCellStyle.ForeColor = Color.White;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜