Click here to Skip to main content
15,888,008 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to Create Class Property for storing splitcontainer panel.....But I can store only splitcontainer...How to store splitcontainer panel...? could you help..? thank for reading................
Posted
Comments
Sergey Alexandrovich Kryukov 23-Dec-11 22:15pm    
What is "storing"?
--SA

1 solution

If you have a Windows Form containing a SplitContainer, and you want objects (Classes, Forms, UserControls, etc.) to have access to that SplitContainer in the Form, there are several strategies you can follow.

One would be to define a Public static Property of Type SplitContainer in the MainForm:
public static SplitContainer MainFormSplitContainer { get; set; }
And then, in the Form Load Event : assign the instance of the SplitContainer in the MainForm to this static Property:
C#
private void MainForm_Load(object sender, EventArgs e)
{
    MainFormSplitContainer = splitContainer1;
}
There are other techniques you could use where, if your MainForm creates the instances of other objects (Forms, UserControls, etc.), you can inject a reference to the instance of the SplitContainer into those created objects by assigning the instance of the SplitContainer to public Properties in those objects, when you create them in the MainForm.
 
Share this answer
 

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



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