单击后,我正在尝试更改数据网格视图中的行标题的颜色。
private void DGV_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
var row = DGV.Rows[e.RowIndex];
row.HeaderCell.Style.BackColor = Color.Yellow;
row.HeaderCell.Style.ForeColor = Color.Yellow;
}但是,颜色永远不会变吗?
发布于 2019-02-28 00:31:50
若要显示与视觉样式颜色不同的颜色,需要将DataGridView的EnableHeadersVisualStyles设置为false。
如果希望行标题在选择行时显示黄色背景色,则有一个比处理行标题的click事件更好的选择:
dataGridView1.EnableHeadersVisualStyles = false;
dataGridView1.RowHeadersDefaultCellStyle.SelectionBackColor = Color.Yellow;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;https://stackoverflow.com/questions/54909802
复制相似问题