moving ellipse over dataGridView
-
Hello everybody. I want to make simple animation. I want to make a moving ellispe over dataGridView . Now I'm write this: private void timer1_Tick(object sender, EventArgs e) { X1 += 5; Y1 += 5; Invalidate(); SolidBrush myBrush = new SolidBrush(Color.Green); dataGridView1.Refresh(); Graphics grfx = dataGridView1.CreateGraphics(); grfx.FillEllipse(myBrush, X1, Y1, 15, 15); } I ask is there any other way to make this because every time when I refresh(); dataGridView it blink. Thanks in advance.
-
Hello everybody. I want to make simple animation. I want to make a moving ellispe over dataGridView . Now I'm write this: private void timer1_Tick(object sender, EventArgs e) { X1 += 5; Y1 += 5; Invalidate(); SolidBrush myBrush = new SolidBrush(Color.Green); dataGridView1.Refresh(); Graphics grfx = dataGridView1.CreateGraphics(); grfx.FillEllipse(myBrush, X1, Y1, 15, 15); } I ask is there any other way to make this because every time when I refresh(); dataGridView it blink. Thanks in advance.
modify your code like this
private void timer1_Tick(object sender, System.EventArgs e) { Graphics gs = dataGrid1.CreateGraphics(); SolidBrush br = new SolidBrush(Color.Red); gs.FillEllipse(br,X,Y,10,10); dataGrid1.Refresh(); if(X+15<= dataGrid1.Width+20) X=X+2; else X=20; } private void dataGrid1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Graphics gs = dataGrid1.CreateGraphics(); SolidBrush br = new SolidBrush(Color.Red); gs.FillEllipse(br,X,Y,10,10); }
-
modify your code like this
private void timer1_Tick(object sender, System.EventArgs e) { Graphics gs = dataGrid1.CreateGraphics(); SolidBrush br = new SolidBrush(Color.Red); gs.FillEllipse(br,X,Y,10,10); dataGrid1.Refresh(); if(X+15<= dataGrid1.Width+20) X=X+2; else X=20; } private void dataGrid1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Graphics gs = dataGrid1.CreateGraphics(); SolidBrush br = new SolidBrush(Color.Red); gs.FillEllipse(br,X,Y,10,10); }
I try to do this but dataGrid1_Paint(); dosn't work private void dataGrid1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Graphics gs = dataGrid1.CreateGraphics(); SolidBrush br = new SolidBrush(Color.Red); gs.FillEllipse(br,X,Y,10,10); }