I've updated your example.
With AutoSize = true, if you set the Anchor property to include AnchorStyles.Right then .Height (and .Bottom) are broken.
With AutoSize = false, if you set the Anchor property to include AnchorStyles.Right then .Height (and .Bottom) are perfect.
I've changed my current solution to set AutoSize to false so I can
properly evaluate the values (since I do the layout calculations last
and all setting, including anchors, is done first). An alternative would
be to always set anchors last.
I cannot attach anything other than images but if you change the click handler to this snippet you will achieve the same behaviour.
01.
private
void
radButton1_Click(
object
sender, EventArgs e)
02.
{
03.
RadDropDownList ddl =
new
RadDropDownList();
04.
//ddl.AutoSize = false;
05.
ddl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
06.
this
.splitPanel1.Controls.Add(ddl);
07.
08.
if
(ddl.Height == 0) MessageBox.Show(String.Format(
"AH! This isn't good! Bottom: {0}, Height: {1}"
, ddl.Bottom, ddl.Height));
09.
10.
RadDropDownList ddl2 =
new
RadDropDownList();
11.
ddl2.Top = ddl.Bottom + 6;
12.
this
.splitPanel1.Controls.Add(ddl2);
13.
}