能不能给些代码.谢谢了.

解决方案 »

  1.   

    靠,整个一行上的所有cell的颜色都设置成红色不就行了
      

  2.   

    上面那为大个,你说的是web吧,我说的是winform
      

  3.   

    public class DataGridTextColorBoxColumn : System.Windows.Forms.DataGridTextBoxColumn
    {
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null;
    private int colornumber=0;
    private int row=0;
    private Color colorname=Color.Olive;
    private System.Data.DataView m_bindDataView; public DataGridTextColorBoxColumn(System.ComponentModel.IContainer container)
    {
    ///
    /// Windows.Forms 类撰写设计器支持所必需的
    ///
    container.Add(this);
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } public DataGridTextColorBoxColumn()
    {
    ///
    /// Windows.Forms 类撰写设计器支持所必需的
    ///
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary> 
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if(components != null)
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    }
    #region 组件设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    components = new System.ComponentModel.Container();
    }
    #endregion protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush foreBrush, bool alignToRight)
    {
    // object  o=this.GetColumnValueAtRow(source,rowNum);  
    // if  (o!=null)  
    // {  
    // if  (o.ToString().SubString(0,1)<="30")  
    // {  
    // backBrush=new  SolidBrush(Color.Red);  
    // }  
    // else  
    // if  (o.ToString().SubString(0,1)>"30")  
    // {  
    // backBrush=new  SolidBrush(Color.Blue);  
    // }  
    // 
    // } 
    // int rownum=row;
    // if((colornumber>100)&&(rownum==rowNum))
    // backBrush=new  SolidBrush(colorname); bool colValue = (Boolean)(this.BindingDataView[rowNum]["check_option"]); 
    if(colValue==true) backBrush=new  SolidBrush(colorname);
    base.Paint (g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
    }
      

  4.   

    将上面的]["check_option"] 换成你要转换的列名,再将这个类替换掉原先你的那个grid中的类,就可以了,至于颜色就无所谓了,可以自己看着办!