DataGridView左键选中行改变行背景色,右键选中行不改变背景色。左键选中行的背景色不变
2016-11-09 23:38
190 查看
private void dataGridView1_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left)//左键 { //刷新上一次选中的行 this.dataGridView1.Rows[RowLeft].DefaultCellStyle.BackColor = Color.White; RowLeft = e.RowIndex; //选中新的行 this.dataGridView1.Rows[e.RowIndex].Selected = true; this.dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Aqua; } else if (e.Button == System.Windows.Forms.MouseButtons.Right)//右键 { this.dataGridView1.Rows[e.RowIndex].Selected = true; //当前活动单元格还保留在上一行的行索引值,所以必须进行赋值更改当前活动单元格的行索引 this.dataGridView1.CurrentCell = this.dataGridView1.Rows[e.RowIndex].Cells[0]; } }
相关文章推荐
- 【前端积累】圆角水平菜单,一张背景图片,选中或鼠标悬停背景的下一部分上移改变背景色
- Jquery实现对a标签改变选中的背景色 支持多选 再次点击背景色消失
- TStringGrid选中某行时改变字颜色和背景色,支持鼠标右键
- dataGridView右键菜单并选中该行
- dataGridView右键菜单并选中该行 http://blog.csdn.net/lanmao100/archive/2009/06/25/4298529.aspx
- 改变tableView中的cell选中的颜色和背景颜色 从父视图上删除所有的子视图
- 改变静态编辑框static text背景色,字体设置及字体背景
- C# 关于在datagridview选中行上添加右键
- GridView单选效果 点击选中一项时,再点击选中另一项时改变背景,原来选中的项取消换回原来的背景
- DataGridView的具体应用(1)-右键单击后选中所在行及弹出上下文菜单,通过事件捕获所选行的ID号及单元格内容
- wpf 设置treeView节点选中后的的文字颜色、节点的背景色以及节点失去焦点后的背景颜色
- DataGridView右键点击行时选中行,并且弹右键快捷菜单
- 改变Windows XP的登录背景图案和背景色
- 【前端开发实例】CSS3 改变选中文本背景色 -(四)
- winform中GridView控件在选中一行后改变选中行的背景颜色
- ListView点击或选中item改变背景
- dataGridView空白列,默认选中行的背景色,dataGridView中加入复选框勾选状态的更改
- CSS3改变文本选中的默认背景颜色
- DataGridView右键选中某单元格(C# Winfrom)
- CSS改变网页中鼠标选中文字背景颜色例子