在VB.Net中动态添加图片框 [英] Adding picture boxes dynamically in VB.Net

查看:108
本文介绍了在VB.Net中动态添加图片框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定那里有人可以清楚地解释这一点.

I'm sure there is someone out there who can explain this clearly.

我会以为我可以简单地使用:

I would have assumed that I could simply use:

Dim pb As PictureBox

然后我可以使用

pb = New PictureBox

但显然不是.

我还假设我可以设置参数

I would also assume I can set parameters

pb.Width
pb.Height
pb.Top
pb.Left

如果有人可以帮助我动态创建一个图片框,可以在其中设置属性,我将非常感谢.

If anyone can help me create a picture box dynamically where I can set the properties I would be so grateful, thanks.

如果已经问过这个问题,我也感到很抱歉,但是我已经找了几个小时,对我没有任何帮助.

I'm also sorry if this question has already been asked, but I have been looking for a few hours now and nothing has worked for me.

推荐答案

换句话说,您正在尝试以编程方式向Windows窗体添加控件.当然,我不知道您尝试了什么,但是我会使用:

In other words, you are trying to add a control to a windows form programmatically. Of course I don't know what you have tried, but I would use:

Dim pb As New PictureBox
pb.Width = 100 'or whatever
pb.Height = 200
pb.Top = 50 'or whatever
pb.Left = 50
pb.ImageLocation = "dog.png"
Me.Controls.Add(pb)

这篇关于在VB.Net中动态添加图片框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆