Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have one mainForm which has splitter contaner divided into two parts left and right. Left panel has some buttons like "Citation". When i clcik on this button it shows the HistoryForm on right panel. Thats good. This HistoryForm has one "New" Button. When i click on this "New" Button on HistoryForm it should display one new for that is "CitationForm" but it is not displaying. I subscribed to and custom event on HistoryForm and trying to display Cutationform from Main form but is not showing. Any help will be appreciated.

Code in Mainform for dispaying is
C#
public void ShowForm(Form sender)
       {
           sender.ControlBox = false;
           sender.FormBorderStyle = FormBorderStyle.None;
           sender.ShowInTaskbar = false;
           sender.TopLevel = false;
           sender.Visible = true;
           sender.Parent = this;

           this.splitContainer2.Panel2.Controls.Clear(); //clear panel first
           this.splitContainer2.Panel2.Controls.Add(sender);
       }



Thanks
AA
Posted

1 solution

You cannot add a form to the controls list of any container - you will get an exception that "A top level control cannot be added..."

Instead of a form, create a custom control, and add that instead.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900