C# Draw when window is loaded
I want to draw some ellipses when the window is loaded
without clicking anything, how can I do it?
My code is the following :
int kerX = random.Next(10,281);
int kerY = random.Next(10,281);
mrPainter.FillEllipse(Brushes.Black, kerX + 10, kerY 开发者_运维问答+ 10, 20, 20);
mrPainter.FillEllipse(blue,65,65,20,20);
mrPainter.FillEllipse(red, 205, 65, 20, 20);
mrPainter.FillEllipse(yellow, 135, 215, 20, 20);
Assuming that your are using WinForms, simply insert the code in the FormLoaded
event of your main form.
精彩评论