比如,当前这一秒每行的背景色是红色;
下一秒变成白色,如此循环,谢谢!

解决方案 »

  1.   

    public Form1()
            {
                InitializeComponent();            dataGridView1.BackgroundColor = Color.White;
            }private void timer1_Tick(object sender, EventArgs e)
            {
                if (dataGridView1.BackgroundColor == Color.White)
                    dataGridView1.BackgroundColor = Color.Green;
                else
                    dataGridView1.BackgroundColor = Color.White;
            }        private void button1_Click(object sender, EventArgs e)
            {
                timer1.Enabled = true;
            }
      

  2.   

    貌似这个更符合你得要求
    private void timer1_Tick(object sender, EventArgs e)
            {
                if (dataGridView1.RowsDefaultCellStyle.BackColor == Color.White)
                    dataGridView1.RowsDefaultCellStyle.BackColor = Color.Red;
                else
                    dataGridView1.RowsDefaultCellStyle.BackColor = Color.White;
            }
      

  3.   

    private void timer1_Tick(object sender, EventArgs e)
            {
    this.dataGridView1.RowsDefaultCellStyle.BackColor =(dataGridView1.RowsDefaultCellStyle.BackColor == Color.Red?Color.White:
     Color.Red;
    this.dataGridView1.AlternatingRowsDefaultCellStyle.BackColor =Color.Red;
    }