How to change datagridview columnname color or style?
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;
精彩评论