重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
当然可以,图像框本身和Form窗体一样,就是个容器控件,可以容纳其他控件
创新互联建站网站建设公司一直秉承“诚信做人,踏实做事”的原则,不欺瞒客户,是我们最起码的底线! 以服务为基础,以质量求生存,以技术求发展,成交一个客户多一个朋友!专注中小微企业官网定制,网站设计制作、网站设计,塑造企业网络形象打造互联网企业效应。
新建一个Winform,拖两个图片框。图片框1在设计器中选择一个图片(尺寸在图片框容纳为佳)。如下代码测试通过:
private void button1_Click(object sender, EventArgs e)
{
Image img1 = this.pictureBox1.Image;
Image img2 = CropToCircle(img1);
this.pictureBox2.Image = img2;
}
public Image CropToCircle(Image img1)
{
Image img2 = new Bitmap(img1.Width, img1.Height,
img1.PixelFormat);
Graphics g = Graphics.FromImage(img2);
using (Brush br =
new SolidBrush(SystemColors.Control))//背景色
{
g.FillRectangle(br, 0, 0,
img2.Width, img2.Height);
}
GraphicsPath path = new GraphicsPath();
path.AddEllipse(0, 0, img2.Width, img2.Height);
g.SetClip(path);
g.DrawImage(img1, 0, 0);
return img2;
}
.....
Px += 0
Py += 20
AddHandler pic(i).Click, AddressOf Pic_Click '添加这一句,绑定单击图片框事件
Next
FlowLayoutPanel1.Controls.AddRange(pic)
End Sub
Dim l As Point, s As Size, f As Boolean
Private Sub Pic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim pic As PictureBox = CType(sender, PictureBox)
If f Then
pic.Location = l
pic.Size = s
f = False
Else
l = pic.Location
s = pic.Size
pic.BringToFront()
pic.Location = FlowLayoutPanel1.Location
pic.Size = FlowLayoutPanel1.Size
f = True
End If
End Sub
Panel控件就是容器,在窗体上添加一个Panel1控件,将其拖放到合适的位置与大小,然后设置Panel1控件的:
AutoScroll 属性为True
Panel1.AutoScrollMinSize 属性
Panel1控件里,添加你的图片框(此时可以滚动Panel1控件里的滚动条)
OK了吧!