Control ClientSize and Size

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,guys

I am confused about Control component 's property
What is the diffenent between ClientSize and Size?
I want to create a customer Panel.
for example:
public calss myPanel:Panel
{
public myPanel()
{
CheckBox cb = new CheckBox();
cb.location = new Point(0,0);
ComboBox cbb = new ComboBox();
//here if I use new Point(cb.Size.Width,0)
//I can not see comboBox, it is covered by CheckBox
//When I watch the cb.Size and ClientSize;
//it is not same.the ClientSize.Width is much more bigger than Size.Width
cbb.location = new Point(cb.ClientSize.Width,0);
Add(cb);
Add(cbb);
}
}

Thanks
 
The "Size" represents the complete height and width of the control, borders
and all. The "ClientSize" represents the height and width of the control not
including the non-client areas such as borders, to name one.

Does the following code work for you?

// CheckBox
CheckBox checkBox1 = new CheckBox();
checkBox1.Bounds = new Rectangle(0, 0, 100, 21);

// ComboBox
ComboBox comboBox1 = new ComboBox();
comboBox1.Bounds = new Rectangle((checkBox1.Left + checkBox1.Width), 0, 100,
21);

this.Controls.Add(checkBox1);
this.Controls.Add(comboBox1);
 
Back
Top