I set (100, 100) for size of a label in the properties and set (100, 100) for another label in my code.
But the sizes are diffrent.(code label is bigger than another)
also depends on my code the two label most sticked together. but result is diffrent!
this is my Form1.cs :
using System;
using System.Drawing;
using System.Windows.Forms;
namespace BBSquare
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Label cell = new Label();
cell.Size = new Size(100, 100);
cell.Location = new Point(100, 0);
cell.BackColor = Color.Blue;
panel.Controls.Add(cell);
}
}
}
this is the result i get : (the left label have (100, 100) size and (0,0) location)
**Edit: this is my Form1.Designer.cs **
namespace BBSquare
{
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.panel = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.panel.SuspendLayout();
this.SuspendLayout();
//
// panel
//
this.panel.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.panel.Controls.Add(this.label1);
this.panel.Location = new System.Drawing.Point(100, 141);
this.panel.Name = "panel";
this.panel.Size = new System.Drawing.Size(600, 600);
this.panel.TabIndex = 0;
//
// label1
//
this.label1.BackColor = System.Drawing.Color.Green;
this.label1.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle;
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(100, 100);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Red;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.ClientSize = new System.Drawing.Size(782, 753);
this.Controls.Add(this.panel);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.panel.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel;
private System.Windows.Forms.Label label1;
}
}