質問

How can I load 2 Images in one PictureBox ?

Here is an example:

http://postimg.org/image/l78kth897/

Thank you so much.

役に立ちましたか?

解決

You can use Graphics.DrawImage() to draw any image anywhere inside a PictureBox or any other control for that matter. If you're writing your own control, override OnPaint(). If you want to use an existing PictureBox, simply use its Paint event to do this:

e.Graphics.DrawImage(YourImageObjectHere, ...);  
e.Graphics.DrawImage(YourSecondImageObjectHere, ...);

GDI+ already supports transparency channel, so if your images have transparent areas, they'll draw just like the sample image you have posted. DrawImage() has over a dozen overloads, using which you can control several aspects of how an image is drawn. The simplest one takes the image object and the position to draw at.

Remember that an image object is an object of System.Drawing.Image or one of its derived classes. If all you have is the path of the image, you should use Image.FromFile() to create an Image object from that image file first.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top