Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#datagridview图形问题cell.style.backcolor_C#_Windows - Fatal编程技术网

c#datagridview图形问题cell.style.backcolor

c#datagridview图形问题cell.style.backcolor,c#,windows,C#,Windows,在我的dev-maschine上,这段代码看起来不错 foreach (DataGridViewRow dgr in dgListe.Rows) { if (dgr.Cells["ColorName"].Value != "" && dgr.Cells["ColorName"].Value != null) { foreach (

在我的dev-maschine上,这段代码看起来不错

            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;
                }
            }
但是在某些电脑上,你会做一些像阴影一样的事情吗?在滚动列表时显示其自身。(附件截图)

OK:(新电脑) ->

N.OK.:(旧电脑) ->


信息:Dotnotfx 4客户端框架,标准winform项目,任何cpu都是黑客攻击,但它对我有效:


在格式化datagridview之前,将默认背景色(如白色)添加到datagridview中。

可能会对某些人有所帮助。此问题的原因可能是argb中的alpha通道。因此,如果您在没有alpha的情况下更改颜色创建方法(如我所做的),问题就可以解决了