运行时控制数组和动态表单生成 [英] Run time Control Array and Dynamic Form Generation

查看:170
本文介绍了运行时控制数组和动态表单生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,
这是我在这个论坛上的处女之谜.
我正在创建动态表单(有多少个?变量...),然后在每个动态表单上添加动态控件(..Command按钮)使用以下代码

设置cmdZoom = d_form(i).Controls.Add("VB.CommandButton","cmdZoom")
现在我想知道单击哪个命令按钮以及采用哪种形式通过处理click事件.但是问题是我仅获得了最后添加的命令按钮的事件.我想处理任何类似控件数组的按钮的click事件.但这不是控件数组,因为每个控件的形式都不相同.那就是我如何知道单击哪个按钮以及在哪个表单上.
信息:---每个动态命令按钮都具有相同的名称.

谢谢.

Hi People,
This is my maiden question in this forum.
I am creating dynamic forms(How many? Variable...) and then adding dynamic control(..Command button) on each dynamic form using following code

    Set cmdZoom = d_form(i).Controls.Add("VB.CommandButton", "cmdZoom")
Now I want to know which command button is clicked and in which form by handling click event.But thing is that i get  event of lastly added command button only.I want to handle click event of any button like control array.But this is not control array coz each control is on different forms.So,my Question is that how do I know which button is clicked and on which form.
Info:--- Each dynamic command button has same name.

Thanks.

推荐答案

要处理所有按钮的click事件,只需向它们添加相同的处理程序.因此,您可能有一个中央处理程序类:

To handle the click event of all buttons, you simply add the same handler to them.  So, you might have a central handler class:

<身体>
ButtonHandler
共享 Sub ButtonClick(( ByVal 发件人 对象 <字体样式="font-size:11px">, ByVal e EventArgs)
'使用按钮
结束 Sub
结束 类别
Class ButtonHandler  
 
    Shared Sub ButtonClick (ByVal sender As ObjectByVal e As EventArgs)  
        ' do stuff with the buttons  
    End Sub 
End Class 
 


这篇关于运行时控制数组和动态表单生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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