Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 如何对代码中创建的对象进行编码?_Vb.net_Winforms_Dynamic Controls - Fatal编程技术网

Vb.net 如何对代码中创建的对象进行编码?

Vb.net 如何对代码中创建的对象进行编码?,vb.net,winforms,dynamic-controls,Vb.net,Winforms,Dynamic Controls,我使用的是vb.net,我不知道如何编写我在代码中创建的picturebox 试试这个: Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim pic As New PictureBox With pic .Name = "pic1" .Size = New Size(250, 250)

我使用的是vb.net,我不知道如何编写我在代码中创建的picturebox

试试这个:

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim pic As New PictureBox
    With pic
        .Name = "pic1"
        .Size = New Size(250, 250)
        .Location = New Point(50, 50)
        .SizeMode = PictureBoxSizeMode.StretchImage
        .Image = Image.FromFile("C:\flower.jpg")
    End With
    Me.Controls.Add(pic)
End Sub
试试这个:

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim pic As New PictureBox
    With pic
        .Name = "pic1"
        .Size = New Size(250, 250)
        .Location = New Point(50, 50)
        .SizeMode = PictureBoxSizeMode.StretchImage
        .Image = Image.FromFile("C:\flower.jpg")
    End With
    Me.Controls.Add(pic)
End Sub
创建的实例,并根据需要设置属性、事件

遵循以下SO线程:和Picture类文档链接了解属性和事件

例如:

Dim WithEvents PictureBox1 As PictureBox

Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click

    PictureBox1.Location = New Point(16, 48)
    PictureBox1.Text = "RadioButton3"
    PictureBox1.Size = New Size(120, 20)
    PictureBox1.Image = _
        Image.FromFile("c:\vbnet\ch07\pictureboxes\image.jpg")
    Me.Controls.Add(PictureBox1)  
End Sub
创建的实例,并根据需要设置属性、事件

遵循以下SO线程:和Picture类文档链接了解属性和事件

例如:

Dim WithEvents PictureBox1 As PictureBox

Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click

    PictureBox1.Location = New Point(16, 48)
    PictureBox1.Text = "RadioButton3"
    PictureBox1.Size = New Size(120, 20)
    PictureBox1.Image = _
        Image.FromFile("c:\vbnet\ch07\pictureboxes\image.jpg")
    Me.Controls.Add(PictureBox1)  
End Sub

你能提供更多的信息吗?你在坚持什么?您尝试过什么?我已经知道如何创建picturebox,我只想对其进行编程。例如,如果我要在代码中创建一个按钮,我将如何确定该按钮的功能?您能否提供更多信息?你在坚持什么?您尝试过什么?我已经知道如何创建picturebox,我只想对其进行编程。例如,如果我要在代码中创建一个按钮,我将如何确定该按钮的功能?