1

I would like make a kind of signaling the red lines make it RED to white every a fiew moment with timer.until now i have made only the color RED without flash this is the code :

private void dataGridViewX1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
  {
   if (DateTime.Parse(dataGridViewX1.Rows[e.RowIndex].Cells[8].Value.ToString()).AddMonths(-1).Month == DateTime.Now.Month)
                {
                    e.CellStyle.BackColor = System.Drawing.Color.Red;}}

until now I have only the color red which appears

So I have tried write some code to get glow ( flashing my color Red with white) in event of Timer control timer_tick but its false i have only the same result

  private void timer1_Tick(object sender, EventArgs e)
    {

        int i = 0;
        while (i < dataGridViewX1.Rows.Count - 1)
        {
            if(
          dataGridViewX1.Rows[i].DefaultCellStyle.BackColor == Color.Red)
            {

           dataGridViewX1.Rows[i].DefaultCellStyle.BackColor = Color.White;
            }
            i++;
        }
    }

1 Answer 1

0
private void timer1_Tick(object sender, EventArgs e)
    {    
        if (dataGridViewX1.RowsDefaultCellStyle.BackColor == Color.Red)
        {
            dataGridViewX1.RowsDefaultCellStyle.BackColor = Color.White;
            return;
        }
        if (dataGridViewX1.RowsDefaultCellStyle.BackColor == Color.White)
        {
            dataGridViewX1.RowsDefaultCellStyle.BackColor = Color.Red;
            return;
        }
     }
20
  • Also I have always the same result only color RED Sorry :( Jan 26, 2014 at 17:26
  • I made a stupid mistake there, now should work if I understood what do you want to achieve.
    – vfioox
    Jan 26, 2014 at 17:36
  • I have tried the new code but is also the same probleme i don't understand why Jan 26, 2014 at 17:44
  • I just checked it, works like a charm. Are you sure the timer's property "Enabled" is set to true?
    – vfioox
    Jan 26, 2014 at 17:45
  • What i want is clear i think make color Red and white or RED and another color the importante thing is make Red dynamic not only color RED Jan 26, 2014 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.