0% found this document useful (0 votes)
10 views8 pages

Loading Form at Runtime

Loading form at runtime

Uploaded by

Eko Heri Susanto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views8 pages

Loading Form at Runtime

Loading form at runtime

Uploaded by

Eko Heri Susanto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 8

Loading Form at

Runtime

Main Form
Click

Menu Click
void BiodataToolStripMenuItemClick(object sender, EventArgs e)
{
LoadAssembly(
"C:\\pekerjaan\\project_mahasiswa.dll",
"project_mahasiswa.MainForm
);
}

Load Form on The Fly


using System.Collections.Generic;
using System.Reflection;
..
void LoadAssembly(string nama_file, string nama_namespace){
try{
Assembly assembly = Assembly.LoadFile(nama_file);
Type type = assembly.GetType(nama_namespace);
object obj = Activator.CreateInstance(type);
Form form = obj as Form;
if (form != null){
form.MdiParent = this;
form.Show();
}
}catch(Exception ex){
MessageBox.Show(ex.Message.ToString());
}
}

Project Baru (Diluar Project Main Menu)

Konfigurasi

Konfigurasi

Class Library

Build Project
Build Solution

File DLL

You might also like