http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q745q
http://expert.csdn.net/Expert/topic/1550/1550919.xml?temp=.4747583

解决方案 »

  1.   

    int RowNum1 = dtGrid商品.CurrentCell.RowNumber;
    dtGrid商品.BackColor = Color.Blue;
      

  2.   

    参考如下代码:
    public class DataGridColoredTextBoxColumn : DataGridTextBoxColumn 
     
         { 
     
              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) 
     
              { 
     
              // the idea is to conditionally set the foreBrush and/or backbrush 
     
              // depending upon some crireria on the cell value 
     
              // Here, we color anything that begins with a letter higher than 'F' 
     
                   try{ 
     
                        object o = this.GetColumnValueAtRow(source, rowNum); 
     
                        if( o!= null) 
     
                        { 
     
                             char c = ((string)o)[0]; 
     
                             if( c > 'F') 
     
                             { 
     
                             // could be as simple as 
     
                             // backBrush = new SolidBrush(Color.Pink); 
     
                             // or something fancier... 
     
                                  backBrush = new LinearGradientBrush(bounds, 
     
                                       Color.FromArgb(255, 200, 200), 
     
                                       Color.FromArgb(128, 20, 20), 
     
                                       LinearGradientMode.BackwardDiagonal); 
     
                                  foreBrush = new SolidBrush(Color.White); 
     
                             } 
     
                        } 
     
                   } 
     
                    catch(Exception ex){ /* empty catch */ } 
     
                   finally{ 
     
                        // make sure the base class gets called to do the drawing with 
     
                        // the possibly changed brushes 
     
                        base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight); 
     
                   } 
     
              } 
     
         }