當DataGridView得到焦點時,其選中行的那條紀錄會有條藍色的高亮度的標記,
那麼當失去焦點時,如何設置它的亮度變暗?
謝謝!

解决方案 »

  1.   

      private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
            {
                this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.AliceBlue;
            }
      

  2.   


    if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onclick", "this.style.backgroundColor='#99cc00'; this.style.color='buttontext';this.style.cursor='default';");
            }
      

  3.   


     //当鼠标离开的时候 将背景颜色还原的以前的颜色
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
      

  4.   

    我說的不是指BackColor,是表示選中的那個顏色
      

  5.   

    WinForm程序。
    就好象是TreeView的HideSelection屬性一樣----當控制項沒有焦點時,從所選去的節點移除反白顯示!DataGridView SelectionMode設置為FullRowSelect
      

  6.   

    this.dataGridView1.Columns[1].DefaultCellStyle.SelectionBackColor = Color.AliceBlue;这只是设置一列的选中背景色.
      

  7.   

    看错了.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;
            }
      

  8.   

    謝謝h_w_king!
    在一個窗體內的2個DataGridView可以達到效果!
    但在2個窗體的DataGridView不能達到效果?
      

  9.   

     没明白什么意思.
    其实就是设置this.dataGridView1.DefaultCellStyle这个属性.
      

  10.   

    我的意思是--有2個窗體A,B,每個窗體都有1個DataGridView,當在B窗體上點擊鼠標時,A窗體上的DataGridView的選中條反白!
    謝謝!
      

  11.   

    首先你要在B窗體能获取A窗體上的DataGridView.
    然后进行相应的设置.