コントロール名(文字列)を使用してコントロールを呼び出す方法:
1384 ワード
string currentButtonName = "buttonLinked";
// 1
Button temButton = (Button)this.GetType().GetField
(currentButtonName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.IgnoreCase).GetValue(this);
// 2
Control c = (Control)System.Activator.CreateInstance(Type.GetType
("System.Windows.Forms. " +currentButtonName+ ", System.Windows.Forms, version=1.0.5000.0, culture=neutral, publickeytoken=b77a5c561934e089 "));
//
string txt = rdbutton.Text;//
// , Enum.Parse
// ListBox1.SelectionMode
listBox1.SelectionMode = (SelectionMode)Enum.Parse(typeof(SelectionMode), txt);