Excuse me!各位,我想在datagridview中实现字体闪烁的效果,可是不知道应该怎么弄?所以请各路英雄能够拔刀相助,还望不吝赐教

解决方案 »

  1.   

    用Timer改变要闪单元格的Style的ForeColor
            private bool bOrg = false;
            private void timer1_Tick(object sender, EventArgs e)
            {
                if (bOrg)
                    this.dataGridView1[0, 0].Style.ForeColor = Color.Black;
                else
                    this.dataGridView1[0, 0].Style.ForeColor = Color.Red;
                bOrg = !bOrg;
            }
      

  2.   

    晕S,ForeBack好象没有相似的地方吧?
      

  3.   

    http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/dbe44fd7-af5e-450e-9087-d5e67038110e/
      

  4.   

    谢谢你的回答。请问:如果是要进行匹配字符后再判断是否闪烁又应该怎么办呢?比如:在datagridview中只要出现“警告”这个字符串时就会闪烁,而不是先设定某个单元格闪烁。
      

  5.   

    private bool bOrg = true;
            private void timer1_Tick(object sender, EventArgs e)
            {
                if (bOrg)
                {
                    for (int i = 0; i < this.dataGridView1.ColumnCount; i++)
                    {
                        for (int j = 0; j < this.dataGridView1.Rows.Count; j++)
                        {
                            this.dataGridView1[i, j].Style.ForeColor = Color.Black;//原色
                        }
                    }            }
                else
                {
                    for (int i = 0; i < this.dataGridView1.ColumnCount; i++)
                    {
                        for (int j = 0; j < this.dataGridView1.Rows.Count; j++)
                        {
                            if (this.dataGridView1[i, j].FormattedValue.ToString().IndexOf("警告") >= 0)
                                this.dataGridView1[i, j].Style.ForeColor = Color.Red;
                        }
                    }
                }
                bOrg = !bOrg;
            }
    如果你的单元格数量非常大时,需要想办法只在当前可视的单元格中查找,方法应该不是太难,今天太晚了,你自己先找找吧