RT,谢谢!datagridviewwinform字体

解决方案 »

  1.   

    建议你用css样式来做,它只是客户关颜色变化,与服务器无关设置两个样式:
    onmousemove="OnMouseOver_DataRow(this)"
    onmouseout="OnMouseOut_DataRow(this)"
      

  2.   

    通过设置OnmouseOver事件来设置为原来颜色
      

  3.   

    是WinForm窗体应用程序  
      

  4.   

    WinForm同样有MouseEnter事件的啊
      

  5.   

    仔细多看几次 msdn保证可以解决
      

  6.   

     dataGridView1.Rows[1].Cells[1].Style.ForeColor = System.Drawing.Color.Red
    没有发现加深问题啊
      

  7.   

    在后台绑定前设置 dataGridView1.DefaultCellStyle.ForeColor = System.Drawing.Color.Red;
      

  8.   

    BackColor ForeColor
    SelectionBackColor SelectionForeColor
    说明你的SelectionForeColor比ForeColor颜色深
      

  9.   

    先将datagridview选中的背景颜色去掉。
    在CellContentClick事件用一个count计数,
    点击一次计一次。  然后根据count来改变字体颜色。
    前提判断选中的是否跟上一次匹配。这样能行?
      

  10.   

    21楼是正解,我没有设置ForeColor的背景颜色。我用你的代码没有变颜色,可能是因为我在编辑列的时候就设置了DefaultCellStyle。感觉DataGridView有好多问题需要注意喔。
      

  11.   

    解决办法在这里,楼主不要纠结了:
    1.设置DataGridView的SelectionMode属性为DataGridViewSelectionMode.FullRowSelect;
    2.实现DataGridView的CellFormatting事件,在其单元格格式发生变化时响应;
    3.实现如下:void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
    {
       DataGridViewRow row = dataGridView1.Rows[e.RowIndex];
       //设置想要的样式,这里只设置字体样式,当前选中行黑体加粗,否则普通文本
       if (row.Selected)
            row.DefaultCellStyle.Font = new Font("黑体",12f,FontStyle.Bold);
       else
           row.DefaultCellStyle.Font = new Font(Font, FontStyle.Regular);
    }其余的当前选中行颜色什么的可以简单设置如下属性:
    dataGridView1.DefaultCellStyle.SelectionBackColor = Color.White;
    dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Red;
      

  12.   

    怎样清掉datagridview选中的背景颜色去掉?这个我没有写过。
      

  13.   

    CellClick 让选中的单元格颜色跟没选中的一样 不就行了嘛