المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Dealing with Controls/ Copy it to a new tabControl



C# Programming
02-18-2010, 10:32 AM
Hi http://www.barakasoft.com/script/Forums/Images/smiley_wink.gif first time for me here at Code Project...
I hope I am right here, with my problem.

I want to copy all controls from the base Form to Tab if a Button is pressed.
The script works so far. Because of that I wanted to write it down in a class.
Now I have the Problem that I dont know what I should send the Function, which parameter..

Please could sbody help me I left 3 hours on this problem :P
Thanks in advance http://www.barakasoft.com/script/Forums/Images/smiley_smile.gif

Here is the Code :
public void Create_Tabs(Control.ControlCollection controls)
{
TabControl tabControl1 = new System.Windows.Forms.TabControl();
TabPage tabPage1 = new System.Windows.Forms.TabPage();
TabPage tabPage2 = new System.Windows.Forms.TabPage();
Control[] c = new Control[controls.Count];
controls.CopyTo(c, 0);


foreach (Control ctr in c)
{
if (ctr is MenuStrip) { }
else tabPage1.Controls.Add(ctr);
}



#region tabControl1,TabPages Definitionen
// Delted this Area; Just the definition for the TabControl,TabPage1 and TabPage2
#endregion
controls.Add(tabControl1);
tabControl1.Controls.Add(tabPage1);
tabControl1.Controls.Add(tabPage2);

}
And here is the call to the function, an also the Problem :
Tab.Create_Tabs( ????? );
"Controls" does not workhttp://www.barakasoft.com/script/Forums/Images/smiley_frown.gif
Hope it is not to long...