Original Post
Language: C# Enviroment: Windows Forms Hi guys. Whenever I try to set the width of my Button to half the width of the container control - Panel - I get a shorter width than the half I wanted.
Does anyone know why this is happening? Thanks, xeddiex
class EmployeePanel : Panel
{
private Button clockIn;
public EmployeePanel()
{
this.Borderstyle = Borderstyle.Fixed3D;
clockIn = new Button();
clockIn.Text = "Clock In";
clockIn.Size = new Size(this.ClientRectangle.Width / 2, this.ClientRectangle.Height);
clockIn.Dock = Dockstyle.Left;
clockIn.Show();
this.Controls.Add(clockIn);
}
}
/* class that creates an instance of the above control: */
class Class1 : Form
{
private EmployeePanel employeePanel;
public Class1()
{
employeePanel = new EmployeePanel();
employeePanel.Size = new Size(this.ClientRectangle.Width, this.ClientRectangle.Height);
this.Controls.Add(employeePanel);
employeePanel.Show();
}
}
Example:
Does anyone know why this is happening? Thanks, xeddiex