I have a windows form that I am displaying as non-modal dialog. As a result I am calling the overloaded Show(IWin32Window owner) method on that form. Only problem is that one of the parent forms that I want to use here is not accessible in the project. As a result I want to load it using reflection using something like code below.
var frm = Assembly.GetEntryAssembly().GetTypes().Where(f => f.Name == "ParentForm").FirstOrDefault();
However this give following compilation errors.
The best overloaded method match for
'System.Windows.Forms.Form.Show(System.Windows.Forms.IWin32Window)' has some invalid arguments
Argument 1: cannot convert from 'System.Type' to 'System.Windows.Forms.IWin32Window'
Any suggestions on how to achieve this?
您可能希望搜索Application.OpenForms
集合。
Form f = Application.OpenForms.Where(x => x.GetType().Name == "ParentForm").FirstOrDefault();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.