dataGridView单元格背景的设置 怎么实现dataGridView选择中行获得焦点的单元格背景的设置,失去焦点后,背景颜色为默认背景 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e) { this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.AliceBlue; } private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e.RowIndex == -1) { //绘制渐变列头 //bool mouseOver = e.CellBounds.Contains(dataGridView1.PointToClient(Cursor.Position)); //LinearGradientBrush brush = new LinearGradientBrush( // e.CellBounds, // mouseOver ? Color.PeachPuff : Color.LightGray, // Color.DarkOrange, // LinearGradientMode.Vertical); //using (brush) //{ // e.Graphics.FillRectangle(brush, e.CellBounds); // Rectangle border = e.CellBounds; // border.Width -= 1; // e.Graphics.DrawRectangle(Pens.Gray, border); //} // 绘制背景色 e.Graphics.DrawImage(global::WindowsApplication6.Properties.Resources.主页0, e.CellBounds.X, e.CellBounds.Y); e.PaintContent(e.CellBounds); e.Handled = true; } } private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e) { this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.AliceBlue; } 当你选择另外一行的时候,上一行的单元格背景没有换成默认背景 怎么处理呢?我就是想在选择的那一行的时候,光标在的单元格换成特殊背景,其他行的单元格为默认背景就可以了 private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e) { this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.AliceBlue; } int index=dgv.SelectedRows[0].Index;当鼠标移开后,this.dataGridView1.Rows[index].Cells[e.ColumnIndex].Style.BackColor = Color.White QQ类软件的服务端是软件还是网站 帮助找出代码中的错误 C# 操作 Excel,调用Excel后关闭进程 C# class library的问题 关于命名空间。错误提示(“Test.Database”是“命名空间”,但此处被当做“类型”来使用) 谁帮我回复,我好结贴?马上给分! 请教关于WebBrowser、MemoryStream问题 [求助]C#多线程问题 测试个加密文件! 关于异步方法调用 怎样放一个按钮点击之后打开一个模式窗体!! c# 压缩
{
this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.AliceBlue;
}
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex == -1)
{
//绘制渐变列头
//bool mouseOver = e.CellBounds.Contains(dataGridView1.PointToClient(Cursor.Position));
//LinearGradientBrush brush = new LinearGradientBrush(
// e.CellBounds,
// mouseOver ? Color.PeachPuff : Color.LightGray,
// Color.DarkOrange,
// LinearGradientMode.Vertical); //using (brush)
//{
// e.Graphics.FillRectangle(brush, e.CellBounds);
// Rectangle border = e.CellBounds;
// border.Width -= 1;
// e.Graphics.DrawRectangle(Pens.Gray, border);
//} // 绘制背景色
e.Graphics.DrawImage(global::WindowsApplication6.Properties.Resources.主页0, e.CellBounds.X, e.CellBounds.Y); e.PaintContent(e.CellBounds);
e.Handled = true;
} }
{
this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.AliceBlue;
}
当你选择另外一行的时候,上一行的单元格背景没有换成默认背景 怎么处理呢?我就是想在选择的那一行的时候,光标在的单元格换成特殊背景,其他行的单元格为默认背景就可以了
{
this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.AliceBlue;
}
this.dataGridView1.Rows[index].Cells[e.ColumnIndex].Style.BackColor = Color.White