Click here to Skip to main content
16,020,877 members
Home / Discussions / Windows Forms
   

Windows Forms

 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
honey.rpk29-Jun-09 19:01
honey.rpk29-Jun-09 19:01 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
Henry Minute29-Jun-09 23:29
Henry Minute29-Jun-09 23:29 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
honey.rpk29-Jun-09 23:57
honey.rpk29-Jun-09 23:57 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
Henry Minute30-Jun-09 0:34
Henry Minute30-Jun-09 0:34 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
honey.rpk30-Jun-09 0:58
honey.rpk30-Jun-09 0:58 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
Henry Minute30-Jun-09 1:08
Henry Minute30-Jun-09 1:08 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
Henry Minute30-Jun-09 1:22
Henry Minute30-Jun-09 1:22 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
honey.rpk30-Jun-09 2:30
honey.rpk30-Jun-09 2:30 
Actually the user control that i have to develop is a combination with two panels one below the other. and the first panel has a buttons and a label on it. Now when ever the button click happens the panel that is present on the down should visible and invisible alternatively.By default it is in 'visible' state.

This is the user control.

And now when i use this usercontrol in a form i should be able to drag controls in to the second panel which is by default visible and all the controls should act as child controls to the user control. I mean when ever we drag the user control they should move along with it..

for that this is the code i have written

partial class tool
{
private System.ComponentModel.IContainer components = null;

protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Component Designer generated code

private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.SandyBrown;
this.panel1.Controls.Add(this.button2);
this.panel1.Controls.Add(this.button1);
this.panel1.Controls.Add(this.label1);
this.panel1.Location = new System.Drawing.Point(14, 13);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(200, 40);
this.panel1.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(136, 5);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(23, 23);
this.button1.TabIndex = 3;
this.button1.Text = "1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(20, 10);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(29, 13);
this.label1.TabIndex = 2;
this.label1.Text = "label";
//
// panel2
//
this.panel2.BackColor = System.Drawing.Color.Peru;
this.panel2.Location = new System.Drawing.Point(14, 47);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(200, 115);
this.panel2.TabIndex = 1;

//
// UserControl1
//
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Name = "UserControl1";
this.Size = new System.Drawing.Size(221, 172);
this.Load += new System.EventHandler(this.tool_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;


private string labeltext;
private Color pnl1color;
private Color pnl2color;







public string Labeltext
{
get
{
return labeltext;
}
set
{
labeltext = value;
label1.Text = labeltext;
}
}


public Color Pnl1color
{
get
{
return pnl1color;
}
set
{
pnl1color = value;
panel1.BackColor = pnl1color;
}
}
public Color Pnl2color
{
get
{
return pnl2color;
}
set
{
pnl2color = value;
panel2.BackColor = pnl2color;
}
}

}




and in .cs file i have written this code



namespace tool
{
[Designer(typeof(ParentControlDesigner))]
public partial class tool : UserControl

{
public tool()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
some code to make panel visible and invisible

}

private void tool_Load(object sender, EventArgs e)
{
panel2.Visible = true;
label1.Text = "enter name of panel";

}


Thats it thats what i did. and when i tried to add controls to the second panel during design time i am not able to do that....


thanks for ur support.....
GeneralRe: How to make a control as a child to user control but not for a form? Pin
Henry Minute30-Jun-09 5:51
Henry Minute30-Jun-09 5:51 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
ice.cool 172930-Jun-09 20:23
ice.cool 172930-Jun-09 20:23 
GeneralRe: How to make a control as a child to user control but not for a form? [modified] Pin
Henry Minute30-Jun-09 6:26
Henry Minute30-Jun-09 6:26 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
dan!sh 30-Jun-09 6:39
professional dan!sh 30-Jun-09 6:39 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
Henry Minute30-Jun-09 8:20
Henry Minute30-Jun-09 8:20 
Generalattn. Henry : small suggestion : Re: How to make a control as a child to user control but not for a form? [modified] Pin
BillWoodruff30-Jun-09 19:11
professionalBillWoodruff30-Jun-09 19:11 
GeneralRe: attn. Henry : small suggestion : Re: How to make a control as a child to user control but not for a form? Pin
Henry Minute30-Jun-09 22:57
Henry Minute30-Jun-09 22:57 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
BillWoodruff30-Jun-09 9:07
professionalBillWoodruff30-Jun-09 9:07 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
honey.rpk30-Jun-09 18:55
honey.rpk30-Jun-09 18:55 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
honey.rpk30-Jun-09 19:46
honey.rpk30-Jun-09 19:46 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
Henry Minute30-Jun-09 22:48
Henry Minute30-Jun-09 22:48 
General[Message Deleted] Pin
ice.cool 17291-Jul-09 0:00
ice.cool 17291-Jul-09 0:00 
GeneralRe: Thanks for solution Pin
Henry Minute1-Jul-09 0:20
Henry Minute1-Jul-09 0:20 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
honey.rpk1-Jul-09 2:37
honey.rpk1-Jul-09 2:37 
GeneralRe: How to make a control as a child to user control but not for a form? Pin
Henry Minute1-Jul-09 4:20
Henry Minute1-Jul-09 4:20 
General[Message Deleted] Pin
ice.cool 17291-Jul-09 18:59
ice.cool 17291-Jul-09 18:59 
GeneralRe: How to reduce size of usercontrol in order to make it exhibit expandable and collapsable features? Pin
Henry Minute1-Jul-09 22:35
Henry Minute1-Jul-09 22:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.