|
Hello,
I need help to get a way to call a mdi form instance by my usercontrol menu. At the Mainform, there is a usercontrol that is part of usercontrol_container.
at the usercontrol; I have a button to call the new form. But I can´t call the method to load the form thought this usercontrol.
I tried to pass it using delegates; but didn´t works well.
Please, see the code bellow:
//MainForm.Designer.cs
private void InitializeComponent() { ////////////////////////////////////////////////////////////////////////// // THIS PARAMETER IS TO SET A DELEGATE FOR "WIZAR MENU" TO GET PARAMETERS // WHEN WIZARD MENU IS ACTIVATED TO CALL A NEW HEADER FORM ////////////////////////////////////////////////////////////////////////// this.uC_Steps1.callmainloadForm += new UCmenus.UC_Steps.CallMainLoadForm(LoadNewFormExternal);
this.uC_Steps1.Dock = System.Windows.Forms.DockStyle.Fill; this.uC_Steps1.Location = new System.Drawing.Point(0, 0); this.uC_Steps1.Name = "uC_Steps1"; toolStripProfessionalRenderer1.RoundedEdges = true; this.uC_Steps1.Renderer = toolStripProfessionalRenderer1; this.uC_Steps1.Size = new System.Drawing.Size(222, 578); this.uC_Steps1.TabIndex = 0;
} // My UserControl Container instance private Template.UCmenus.UC_Steps uC_Steps1;
//USER CONTROL CONTAINER
private UC_MenuSteps _menusteps; private UC_MenuSTart _menustart; // private static string testvoid;
public UC_Steps() { InitializeComponent(); InitializeMenu(); }
public void InitializeMenu() { _menustart = new UC_MenuSTart(); _menusteps = new UC_MenuSteps();
//DELEGATE TO USE AT USERCONTROL ITEM _menusteps.callmainloadFormMenu += new UC_MenuSteps.CallMainLoadFormMenu(SendHeaderFormComfirm);
IDockingPanel leftPanel = this.Panels[DockingType.Left].InsertPanel(0); leftPanel.Tabbed = true; IDockingControl dock2 = leftPanel.DockedControls.Add("Getting Started", _menustart); IDockingControl dock3 = leftPanel.DockedControls.Add("Template Steps", _menusteps);
//user control item that calls the form
public delegate void CallMainLoadFormMenu(object sender, FormValues myformvalues); public CallMainLoadFormMenu callmainloadFormMenu;
private void btnCallForm1_Click(object sender, EventArgs e) { if (callmainloadFormMenu != null) { FormValues formvalues = new FormValues(ht, "Edit Template");
callmainloadFormMenu(this, formvalues); } }
Does anyone can help me with this issue??
Tks Vagner |