c# - Can't draw on Picturebox -
suppose have form picturebox on it:
where problem? rectangle disapears on picture box. why?
private void picturebox1_paint(object sender, painteventargs e) { graphics gr = picturebox1.creategraphics(); gr.fillrectangle(brushes.red, new rectangle(10, 10, 50, 50)); }
i checked , yeah case mentioned in comments.
the problem not taking reference of graphics when painting instead pushing rectangle in picturebox's graphics wont rendered.
to right need use e.graphics
refrence on graphic going painted.
so correct code is:
private void picturebox1_paint(object sender, painteventargs e) { graphics gr = e.graphics; gr.fillrectangle(brushes.red, new rectangle(10, 10, 50, 50)); }
Comments
Post a Comment