private void AddButton(ButtonHelperClass btnInfo) { Button btn = new Button(); btn.Name = btnInfo.ButtonName; btn.Size = new Size(130, 32); btn.TabIndex = panel.Controls.Count; btn.Text = btnInfo.ButtonText; btn.Margin = new Padding(5, 3, 15, 3); btn.UseVisualStyleBackColor = true; btn.Click += (btnInfo.Click != null ? btnInfo.Click : new System.EventHandler(this.button_Click)); btn.Tag = btnInfo; panel.Controls.Add(btn); }
private void button_Click(object sender, EventArgs e) { try {//For run in mono Button btn = (Button)sender; ButtonHelperClass btnInfo = (ButtonHelperClass)btn.Tag; Type frmType = Type.GetType(btnInfo.ClassName); if (frmType != null) { System.Reflection.ConstructorInfo oConstructorInfo = frmType.GetConstructor(System.Type.EmptyTypes); Form frm = (Form)oConstructorInfo.Invoke(null); ShowForm(frm); } else { btnInfo.Click(sender, e); } } catch (Exception exc) { MessageBox.Show(exc.StackTrace + Environment.NewLine + exc.Message); } }