drawing on picture box

J

jack

hi all can any one help me in this
i want to draw a default picture on a picture box whenever i click
on a new button. please help ...
 
J

John Richardson

probably the easiest way to achieve this is to sub-class the button class,
and override the paint method to paint in your custom image.
Graphics.DrawImage() should work, but you will need to code in sizing stuff
for your image... I'd write some out for you, but I'm toooo tired. You
should be able to google some examples of how to override the paint method
properly.
 
N

Nicholas Paldino [.NET/C# MVP]

Jack,

This is easy. Create a new Bitmap instance, and then get the Graphics
instance by passing the bitmap to the static FromImage method on the
Graphics class. This will return a Graphics instance you can use to draw on
the image.

Once you have that, you can set the PictureBox to show the image that
you created.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top