graphics - C# drawing issue -
i have general question drawing in c#. in class test
have method draw:
public void draw(graphics g) { g.drawline(pens.black, x1, y1, x2, y2); }
and want draw in main form in picturebox called picturebox1
but how can draw it?
normally can draw in picturebox this:
private void draw() { graphics g = picturebox1.creategraphics(); g.drawline(pens.black, x1, y1, x2, y2); }
i know silly question, beginner , want basics ;)
best wishes :)
edit:
sorry, don't understand postings @ all, can explain me again
edit 2:
thanks answers. don't know how works.
there class test , in class there draw method:
private void draw() { graphics g = picturebox1.creategraphics(); g.drawline(pens.black, x1, y1, x2, y2); }
now want draw methode in picturebox in mainclass formmain
how can draw test.draw() in picturbox in other class?
i hope clear , sorry inexperience best wishes
the picturebox control overwrite whatever on each time paint event gets fired (which pretty time). need wire event:
this.picturebox1.paint += new painteventhandler(picturebox1_paint);
then in event drawing:
void picturebox1_paint(object sender, painteventargs e) { // assuming constructor takes coordinates parameters var t = new test(0, 0, 100, 100); t.draw(e.graphics); }
Comments
Post a Comment