通用的开放式功能 [英] generic open form function
本文介绍了通用的开放式功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何提示将是非常有用的。
它是winforms + vb.net
谢谢
TR
解决方案
你的意思是这样吗?
(b)$ b $ $ $ $ $ $ $ $ $ $ $ $ $ b F dlg = new F();
dlg.MdiParent = this;
dlg.Show();
return dlg;
VB.NET
公共函数启动(F作为{Form,New})()作为F
Dim dlg作为新F()
dlg.MdiParent = Me
dlg.Show()
返回dlg
结束功能
has anyone written a generic "LaunchForm" function? For all the menu items I have that open a form, I would like to write one function that will launch the form as opposed to writing the same code several times.
any tips would be very helpful.
It's winforms + vb.net
thanks TR
解决方案
You mean something like this?
C#
public F Launch<F>() where F : Form, new()
{
F dlg = new F();
dlg.MdiParent = this;
dlg.Show();
return dlg;
}
VB.NET
Public Function Launch(Of F As {Form, New})() As F
Dim dlg As New F()
dlg.MdiParent = Me
dlg.Show()
Return dlg
End Function
这篇关于通用的开放式功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文