Hi friends,
I am having trouble overriding properties of a user control I have created.
I have a panel within the control that acts as the control's border. I would want it to resize accordingly as the control's size changes. It does it fine at run-time. But whenever, I do drag-n-drop at design-time, it does not resize automatically. What am I doing wrong?
This is what I am doing.
I am having trouble overriding properties of a user control I have created.
I have a panel within the control that acts as the control's border. I would want it to resize accordingly as the control's size changes. It does it fine at run-time. But whenever, I do drag-n-drop at design-time, it does not resize automatically. What am I doing wrong?
This is what I am doing.
Code:
namespace XYZButtonPane
{
/// <summary>
/// Summary description for XYZButtonPane.
/// </summary>
public class XYZButtonPane : System.Windows.Forms.UserControl
{
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Panel pnlBorder;
#region Member Variables
private int m_intWidth = 100;
private int m_intHeight = 200;
#endregion
#region Properties
new public int Width
{
get
{
return m_intWidth;
}
set
{
m_intWidth = value;
this.pnlBorder.Width = value;
}
}
new public int Height
{
get
{
return m_intHeight;
}
set
{
m_intHeight = value;
this.pnlBorder.Height = value;
}
}
#endregion
public XYZButtonPane()
{
InitializeControls();
}
private void InitializeControls()
{
this.pnlBorder = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// pnlBorder
//
this.pnlBorder.Location = new System.Drawing.Point(0, 0);
this.pnlBorder.Name = "pnlBorder";
this.pnlBorder.BorderStyle = BorderStyle.FixedSingle;
//
// XYZButtonPane
//
this.Name = "XYZButtonPane";
this.Size = new Size(this.m_intWidth, this.m_intHeight);
this.pnlBorder.Size = new Size(this.m_intWidth, this.m_intHeight);
this.Resize += new System.EventHandler(this.XYZButtonPane_Resize);
this.Controls.Add(this.pnlBorder);
this.Name = "XYZButtonPane";
this.ResumeLayout(false);
}
private void XYZButtonPane_Resize(object sender, System.EventArgs e)
{
this.pnlBorder.Height = this.Height;
this.pnlBorder.Width = this.Width;
}
}
}