設置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; } if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onclick", "this.style.backgroundColor='#99cc00'; this.style.color='buttontext';this.style.cursor='default';"); } //当鼠标离开的时候 将背景颜色还原的以前的颜色 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';"); 我說的不是指BackColor,是表示選中的那個顏色 WinForm程序。就好象是TreeView的HideSelection屬性一樣----當控制項沒有焦點時,從所選去的節點移除反白顯示!DataGridView SelectionMode設置為FullRowSelect this.dataGridView1.Columns[1].DefaultCellStyle.SelectionBackColor = Color.AliceBlue;这只是设置一列的选中背景色. 看错了.sorry private void dataGridView1_Leave(object sender, EventArgs e) { this.dataGridView1.DefaultCellStyle.SelectionBackColor = this.dataGridView1.DefaultCellStyle.BackColor; } private void dataGridView1_Enter(object sender, EventArgs e) { this.dataGridView1.DefaultCellStyle.SelectionBackColor = System.Drawing.SystemColors.Highlight; } 謝謝h_w_king!在一個窗體內的2個DataGridView可以達到效果!但在2個窗體的DataGridView不能達到效果? 没明白什么意思.其实就是设置this.dataGridView1.DefaultCellStyle这个属性. 我的意思是--有2個窗體A,B,每個窗體都有1個DataGridView,當在B窗體上點擊鼠標時,A窗體上的DataGridView的選中條反白!謝謝! 首先你要在B窗體能获取A窗體上的DataGridView.然后进行相应的设置. ListBox控件如何改变选中项的颜色-WinForm 请教一个通讯问题(高手请进) C#调用C++的工具 路径问题 请教高手 c#中服务器接收数据,socket如何接收一个struct?!!! .Net的默认编码方式是什么? Datagridview如果加入一个combox要点三下鼠标才可以选东西,有什么好方法少点几下. 求助!本人要一个游戏外挂 关于工资计算公式的问题,关于工资计算公式的问题 文件删除问题 GridView 取值问题 c#.net 求救!!!!!!如何实现用户不登陆就不可以发帖的功能????????在线等
{
this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.AliceBlue;
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", "this.style.backgroundColor='#99cc00'; this.style.color='buttontext';this.style.cursor='default';");
}
//当鼠标离开的时候 将背景颜色还原的以前的颜色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
就好象是TreeView的HideSelection屬性一樣----當控制項沒有焦點時,從所選去的節點移除反白顯示!DataGridView SelectionMode設置為FullRowSelect
{
this.dataGridView1.DefaultCellStyle.SelectionBackColor = this.dataGridView1.DefaultCellStyle.BackColor;
} private void dataGridView1_Enter(object sender, EventArgs e)
{
this.dataGridView1.DefaultCellStyle.SelectionBackColor = System.Drawing.SystemColors.Highlight;
}
在一個窗體內的2個DataGridView可以達到效果!
但在2個窗體的DataGridView不能達到效果?
其实就是设置this.dataGridView1.DefaultCellStyle这个属性.
謝謝!
然后进行相应的设置.