12.07.2014

找出目前執行檔的所有的表單

public class FormsCollection : CollectionBase
{
public Form Add(Form FormObject)
{
base.List.Add(FormObject);
return (FormObject);
}

public void Remove(Form FormObject)
{
base.List.Remove(FormObject);
}
}
走訪的方式
Type form = typeof(Form);
foreach (Type item in Assembly.GetExecutingAssembly().GetTypes())
{
//if (item.BaseType == typeof(Form))
if (item.Name.StartsWith("Frm_"))
{
Form f = (Form)Activator.CreateInstance(item);
forms.Add(f);
}
}

資料來源:微軟知識庫