面板中PictureBox的图像

面板中PictureBox的图像

本文介绍了面板中PictureBox的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个图片框控件数组,因此我使用了一个面板来容纳它们.但是,之后我发现该图像已被禁用.我必须改为使用BackgroundImage吗? :(

I wanna create an array of picturebox controls, so I used a panel to hold them. However, afterwards I found that the Image has been disabled. Do I have to use BackgroundImage instead? :(

推荐答案

Panel1.Image = new Image(@"c:\...

,但是编译器抱怨.
Panel控件不具有Image属性(irt具有BackgroundImage,但这不是您想要的).您需要做的是改为设置每个PictureBox控件的Image属性.

您是否已将PictureBox控件添加到Panel.Controls列表中?
您是否给他们提供了所有新的位置"属性和适当的大小?
如果您有很多图像,最好使用Paint事件自己绘制它们.

but the compiler complained.
A Panel control does not have an Image property (irt does have a BackgroundImage, but this is not what you want). What you need to do is set the Image property of each PictureBox control instead.

Have you added the PictureBox controls to the Panel.Controls list?
Have you given them all new Location properties, and appropriate sizes?
If you have many images, you may be better off drawing them yourself with the Paint event.


<br />
           PictureBox[] Pix = new PictureBox[10];<br />
           for (int i = 0; i < 10; i++)<br />
           {<br />
               Pix[i] = new PictureBox();<br />
               Pix[i].Image = Image.FromFile(@"C:\bmp.bmp");<br />
               Pix[i].SizeMode = PictureBoxSizeMode.StretchImage;<br />
               Pix[i].Name = string.Format("Image{0}", i);<br />
               Pix[i].Size = new Size(10, 10);<br />
               Pix[i].Location = new Point(i * 10, 0);<br />
               panel1.Controls.Add(Pix[i]);<br />
           }<br />



----------------------
问候

H.Maadani



----------------------
Regards

H.Maadani


这篇关于面板中PictureBox的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 06:01