点击按钮之前效果:
点击按钮之后的效果:
实现按钮点击代码:
//以下代码都可以试试
private void Button_Delete_leave_Click(object sender, EventArgs e)
{
DataGridView_Participants.SelectedRows[0]
.DefaultCellStyle.SelectionForeColor = Color.Red;
}
/*
private void dgv_RowEnter(object sender, EventArgs e)
{ DataGridView_Participants.SelectedRows[0].DefaultCellStyle.SelectionForeColor = Color.Red;
//DataGridView_Participants.Rows[e.RowIndex].DefaultCellStyle.SelectionForeColor = Color.Red;
}*
*/
//测试:背景色只能设置一次,不能根据选中行的某个值去判断赋值,
if()
{
this.dgv.RowTemplate.DefaultCellStyle.SelectionForeColor = Color.Red;
}
else if()
{
this.dgv.RowTemplate.DefaultCellStyle.SelectionForeColor = Color.Yellow;
}
else
{
this.dgv.RowTemplate.DefaultCellStyle.SelectionForeColor = Color.Blue;
}
//this.dgvFaFangDMX.RowTemplate.DefaultCellStyle.SelectionForeColor = Color.Red;