我想自己做一个控件,这个控件上可以自己画图,也可以在上边不同位置同时放若干图片,而且可能是自绘图做为底图然后再在某些位置放置小图片,因为都是不确定的,所以应该是只能把某一个控件做为容器,我现在用的是pictureBox,可是不知道怎么在PictureBox上同时显示多个图片。
请问:
(1)是不是PictureBox最适合我的要求?
(2)怎样在PictureBox上若干位置上同时显示几个图片?
我是新手也是菜鸟,请多指教

解决方案 »

  1.   

    这个要求没办法用PictureBox实现,只能够直接重载OnPaint方法,在其中调用Graphic的方法绘制图片。
      

  2.   

    我是在Onpaint函数里绘制图形了,可是不会显示图片
    请问Mittermeyer:“在其中调用Graphic的方法绘制图片”怎么做?能详细点吗?我一点头绪没有
      

  3.   

    基本上能实现了,只不过是将bmp转换为ico格式再显示
      

  4.   

    Graphics::DrawImage 方法 。例如:protected override void DrawImageRectRect(PaintEventArgs e)
    {    // Create image.
        Image newImage = Image.FromFile("SampImag.jpg");    // Create rectangle for displaying image.
        Rectangle destRect = new Rectangle(100, 100, 450, 150);    // Create rectangle for source image.
        Rectangle srcRect = new Rectangle(50, 50, 150, 150);
        GraphicsUnit units = GraphicsUnit.Pixel;    // Draw image to screen.
        e.Graphics.DrawImage(newImage, destRect, srcRect, units);
    }
      

  5.   

    1.可以由一个Button触发几个picturebox可以达到你的效果。
    2.也可以用picturebox设置几个数组达到这个效果
    3.LZ的想法很好,可以考虑自定义控件。