Vb.net无法添加按钮 [英] Vb.net failed to add button

查看:72
本文介绍了Vb.net无法添加按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试以编程方式将按钮添加到vb中

但是我的按钮没有加载到表单中..



我能知道吗是我的问题?



我尝试了什么:



  Dim  _button() As 按钮
Dim _x 作为 整数 = 20
Dim _y()作为 整数 = { 0 50 100 150 200 250 300 350 400 450 }

对于 i 作为 整数 = 1 10
ReDim _button(i)
使用 _button(i)
.Visible = 1
.Text = i
.Size = 大小( 20 50
.Location = 点(_x ,_y(i - 1 ))

Controls.Add(_button(i))

结束 使用
下一步

解决方案

你不创建一个对象!

试试这样:

<前lang =vb> Dim _button() As 按钮
Dim _x 作为 整数 = 20
Dim _y()作为 整数 = { 0 50 100 150 200 250 300 350 400 450 }

对于 i 作为 整数 = 1 10
_button = 按钮
' 等等


I try to add button into vb programatically
but my button did not load in the form..

can i know what is my problem?

What I have tried:

Dim _button() As Button
Dim _x As Integer = 20
Dim _y() As Integer = {0, 50, 100, 150, 200, 250, 300, 350, 400, 450}

For i As Integer = 1 To 10
    ReDim _button(i)
    With _button(i)
        .Visible = 1
        .Text = i
        .Size = New Size(20, 50)
        .Location = New Point(_x, _y(i - 1))

        Controls.Add(_button(i))

    End With
Next

解决方案

You don't create an object!
Try it like this:

Dim _button() As Button
Dim _x As Integer = 20
Dim _y() As Integer = {0, 50, 100, 150, 200, 250, 300, 350, 400, 450}
 
For i As Integer = 1 To 10
  _button = New Button
  ' and so long


这篇关于Vb.net无法添加按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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