Image Drawing with Graphics C# -


i want draw image in picture box, , image not drawing wrong code? thanks

        bitmap b;     private void form1_load(object sender, eventargs e)     {           b = new bitmap(1000, 100);         picturebox1.image = b;         graphics g = picturebox1.creategraphics();         rectangle rect = new rectangle(20, 20, 70, 70);         image earth =  image.fromfile("" + system.io.directory.getcurrentdirectory() + @"\earth.png");         g.drawimage(earth,rect);        } 

form.load fires before drawn screen. when form displayed first time, picturebox.onpaint called , control render default appearance. draw picturebox, handle paint event , drawing in event handler using supplied graphics instance. event fired every time part of control redrawn, allow draw graphics persist when control invalidated. see here more information.


Comments