通过设置DataGridView.DataSource 为DateSet 显示数据库数据怎样自动让数据为负数的时候显示为红色?

解决方案 »

  1.   

    简单点的方法是...在数据绑定后,用For循环遍历您要控制的列...如果为负数,就改变其单元格的颜色...
      

  2.   

    CellFormating事件里搞定能不能给说说啊 有例子吗?
      

  3.   

    private void view_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
    {
        if (e.Value == null)
         return;
        if (viewLeft.Columns[e.ColumnIndex].Name="colname" && int.Parse(e.Value.ToString()<0)
         {
            e.CellStyle.BackColor = Color.Red;
         }
    }
      

  4.   

    CellFormatting 这个事件是从哪里弄出来的呀?
      

  5.   

    加入ASP。NET C#群吧,群号是:  1873156
      

  6.   

    DataGridView自带的事件
    可手动写
    this.dtview.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dtview_CellFormatting);
    也可以在DataGridView的属性窗口 选择"事件" 双击 CellFormatting 添加
      

  7.   

    请问这个e.Value.ToString() 代表什么 ?