一些具有挑战性的问题 [英] Some challanging question

查看:84
本文介绍了一些具有挑战性的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我有项目.

在我的项目中,我正在运行时创建新表单.

当新的打开时,我想以新的形式编写一些加载事件.


你们可以向我解释或给我

Hi all

I have project.

In my project I am creating new form at runtime.

When that new opened I want write some load event in that new form.


You people can explain me or give me the coding for that

推荐答案

的代码,请看以下示例代码.窗体上有一个按钮.单击该按钮时,创建一个新表单,将处理程序附加到Load事件,然后显示新表单.

将触发处理程序,并显示带有新表单名称的消息框;

Look at the following example code. A Form has a Button on it. The button when clicked, create a new form, attaches a handler to the Load event and then displays the new form.

The handler is fired and a message box with the new forms name is displayed;

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    'Create a new form
    Dim FormX As New Form
    FormX.Name = "SomeForm"
    AddHandler FormX.Load, AddressOf SomeHandlerFunction
    FormX.Show()
End Sub

Public Sub SomeHandlerFunction(ByVal sender As System.Object, ByVal e As System.EventArgs)
    'What Object raised Me
    If TypeOf (sender) Is Form Then
        Dim theNewForm As Form = CType(sender, Form)
        MsgBox(theNewForm.Name + " was loaded.")
    End If
End Sub


这篇关于一些具有挑战性的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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