My Problem :
There a UserControl and there is a button inside the user control
The user control has a public method(HideMyButton) and all it does is
hide the button inside the user control

Now, I placed this user control in one of my forms and then Call
HideMyButton method on the user control. This doesn't hide the button inside
the user control. Why is that?

Thanks

Shankar

Re: Windows Form User Control by Bob

Bob
Thu Nov 30 17:43:53 CST 2006

Please post the code you use to hide the button and we'll see what's going
on.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.



<shankar@ozcap.com> wrote in message
news:%23M2v%23DNFHHA.3304@TK2MSFTNGP05.phx.gbl...
> My Problem :
> There a UserControl and there is a button inside the user control
> The user control has a public method(HideMyButton) and all it does is
> hide the button inside the user control
>
> Now, I placed this user control in one of my forms and then Call
> HideMyButton method on the user control. This doesn't hide the button
> inside
> the user control. Why is that?
>
> Thanks
>
> Shankar
>
>



Re: Windows Form User Control by shankar

shankar
Fri Dec 01 09:34:41 CST 2006

Here are the User Control with a button and text box on it

partial class UserControl1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Component Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(112, 30);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(112, 87);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 1;
//
// UserControl1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Name = "UserControl1";
this.Size = new System.Drawing.Size(339, 150);
this.Load += new System.EventHandler(this.UserControl1_Load);
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
}

public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}

private void UserControl1_Load(object sender, EventArgs e)
{

}
// method to hide button and text box
public void HideThis()
{
button1.Visible = false;
textBox1.Visible = false;
}
}



Here is the code to Windows Forms. This Form contains the above user
control. Another Button is also placed in the Form. I

partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.userControl11 = new WindowsApplication8.UserControl1();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(171, 215);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new
System.EventHandler(this.button1_Click);
//
// userControl11
//
this.userControl11.Location = new System.Drawing.Point(51, 28);
this.userControl11.Name = "userControl11";
this.userControl11.Size = new System.Drawing.Size(339, 150);
this.userControl11.TabIndex = 1;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(441, 273);
this.Controls.Add(this.userControl11);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.Button button1;
private UserControl1 userControl11;
}


public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
userControl11.HideThis();
}
}
"Bob Powell [MVP]" <bob@_spamkiller_.bobpowell.net> wrote in message
news:uCnTslNFHHA.2112@TK2MSFTNGP03.phx.gbl...
> Please post the code you use to hide the button and we'll see what's going
> on.
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Ramuseco Limited .NET consulting
> http://www.ramuseco.com
>
> Find great Windows Forms articles in Windows Forms Tips and Tricks
> http://www.bobpowell.net/tipstricks.htm
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/faqmain.htm
>
> All new articles provide code in C# and VB.NET.
> Subscribe to the RSS feeds provided and never miss a new article.
>
>
>
> <shankar@ozcap.com> wrote in message
> news:%23M2v%23DNFHHA.3304@TK2MSFTNGP05.phx.gbl...
> > My Problem :
> > There a UserControl and there is a button inside the user control
> > The user control has a public method(HideMyButton) and all it does
is
> > hide the button inside the user control
> >
> > Now, I placed this user control in one of my forms and then Call
> > HideMyButton method on the user control. This doesn't hide the button
> > inside
> > the user control. Why is that?
> >
> > Thanks
> >
> > Shankar
> >
> >
>
>