使用参数打开表格 [英] Open Form with Parameters
问题描述
我有一个DLL文件(myForms.DLL)文件,其中包含一个表单(form1),
显示重载,并带有一个这样的参数:
公共重载子节目(ByVal数据作为dataTable)
......
结束Sub
而且,我有一个没有DLL参考的EXE项目,我想打开EXE项目中myForms.DLL中存在的form1.我加载了myForms.DLL程序集,并得到了像这样的form1:
.....
.....
以窗体= CType(Activator.CreateInstance(typ),Form)的形式暗化f
现在,我想显示带有参数的表格:
将mydata调暗为新的datatabe
f.show(mydata)
我的问题是,表单无法识别Parameter或Overloads Show()并始终显示原始表单.如何使用参数打开此表单?
thanx
i have a DLL file (myForms.DLL) file which contains one form (form1),
with overloads show, with one parameter like this:
Public Overloads Sub Show(ByVal Data As dataTable)
......
end Sub
and, i have an EXE Project without reference for DLL, i want to open the form1 which exist in myForms.DLL in EXE Project. I loaded the myForms.DLL assembley and get the form1 like this:
.....
.....
dim f as form = CType(Activator.CreateInstance(typ), Form)
now, i want to show the form with parameter:
dim mydata as new datatabe
f.show(mydata)
my problem is, the form can not identify the Parameter or Overloads Show() and always Show the original form. How can i open this form with parameter?
thanx
推荐答案
将表单创建为表单类型,而不是Form.由于Form对您重载的Show方法一无所知,因此将无法正常工作.
Create the form as your form type, not Form. Since Form knows nothing of your overloaded Show method, it''s not going to work.
Dim f as MyForm = CType(Activator.CreateInstance(typ), MyForm)
戴夫,
我知道,但是我不能使用表单类型,因为我没有DLL的引用.
我使用type和getAssembly从DLL文件中提取了表单对象.
hi Dave,
i know that but i can not use form type coz i have no reference for the DLL.
i extracted the form object from DLL file using type and getAssembly.
这篇关于使用参数打开表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!