在运行时的一个按钮单击事件中创建多个按钮的代码 [英] code to create multiple buttons in one button click event in runtime
本文介绍了在运行时的一个按钮单击事件中创建多个按钮的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
用户控件,例如按钮,应该在我单击按钮单击事件时多次创建.
谢谢你
A user control, eg. button, should be created however many times I want when I click that button click event.
Thank You
推荐答案
如果我正确理解了你的问题,就会发现
If I understand your question correctly, you''ll find the basics here.
dim btn as new button
btn.name = "ButtonName"
btn.text = "ButtonText"
btn.left = 100
btn.top = 100
me.controls.add(btn)
addhandler btn.cli, addressof BtnEvent
...
public sub BtnEvent
end sub
您将需要更改以下部分,以确保您的按钮在每次使用时都可见,否则要绘制的下一个按钮将覆盖前一个按钮.
you will need to change the section below to make sure your button is visible to the use each time else the next button to be drawn will overwrite the previous
btn.left = 100
btn.top = 100
< code>您可以从文本框中创建按钮!
dim c as integer = 10''此变量用于形式的位置,您可以用于left,top
dim z as integer = 100''此变量用于表示形式中的位置,可以用于left,top
将我暗淡为整数
对于i = 0到textbox.text
将btn设为新按钮
btn.name ="Button"&我
btn.text = i
btn.location =新的drawing.point(c,z)
me.controls.add(btn)
z = z + 100
下一个
</code>
<code>you ca create buttons from textbox!
dim c as integer=10 '' this variable is for location in form, you can use for left,top
dim z as integer=100 '' this variable is for location in form, you can use for left,top
dim i as integer
for i=0 to textbox.text
dim btn as new button
btn.name="Button" & i
btn.text=i
btn.location= new drawing.point(c,z)
me.controls.add(btn)
z=z+100
next
</code>
这篇关于在运行时的一个按钮单击事件中创建多个按钮的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文