2013-10-02 65 views
0

在我的开发maschine这个代码看起来不错。c#datagridview图形问题cell.style.backcolor

  foreach (DataGridViewRow dgr in dgListe.Rows) 
      { 
       if (dgr.Cells["ColorName"].Value != "" && dgr.Cells["ColorName"].Value != null) 
       { 
        foreach (DataGridViewCell drgc in dgr.Cells) { 
         drgc.Style.BackColor = Color.FromName(dgr.Cells["ColorName"].Value.ToString()); 
        } 

       } 
      } 

工作不如

  foreach (DataGridViewRow dgr in dgListe.Rows) 
      { 
       if (dgr.Cells["ColorName"].Value != "" && dgr.Cells["ColorName"].Value != null) 
       { 

        DataGridViewCellStyle zs = new DataGridViewCellStyle(); 
        zs = dgr.DefaultCellStyle; 
        zs.BackColor = Color.FromName(dgr.Cells["ColorName"].Value.ToString()); 
        dgr.DefaultCellStyle = zs; 
       } 
      } 

但在某些pc's像做一个shaddow副本?在滚动列表时它是自己的。 (ATT截图)

确定:(新PC's) - >

enter image description here

N.OK:(旧PC's) - >

enter image description here

信息:Dotnotfx 4客户端框架,std。 WinForm的项目,任何CPU

回答

0

是一个黑客,但它的工作对我来说:

添加默认背景色(如白色)到DataGridView格式化之前。