Trouble with Anchor

I am programming VS 2005 for window mobile 2005 w/ the vga smart phone emulator. I dynamically create a Label l. I add it to an Array of Label ls, and the controls collection of the form. If, I anchor it Left it displays on the form, but if I anchor it to the right it is moved off the display area. If I do not anchor it, the right side list box displays fine.

Is this a bug? If I comment out the bold line below it displays fine. But it is not anchored.

if(i % 2 == 0)
{
pb.Left =
ConfigurationHelper.IconSidePadding;
l.TextAlign =
ContentAlignment.TopLeft;
ls[ i ].Anchor =
AnchorStyles.Left |AnchorStyles.Top;
}
else
{
pb.Left =
this.Width - pb.Width -ConfigurationHelper.IconSidePadding;
l.TextAlign =
ContentAlignment.TopRight;
ls[ i ].Anchor =
AnchorStyles.Right|AnchorStyles.Top;
}

Also if i set the anchor of l it behaves differnetly than if I set ls[ i ]. What are the refference differences in CF. I though if I assign ls[ i ]=l that i could set properties of either and they would work the same. But I keep recreating l and it looks like some properties assigned to l are lost. Why? Is there a discription some where?

[2272 byte] By [AllenAlper] at [2008-2-14]
# 1
One possibility is that your form size is greater than the size of the screen or you have turn on AutoScroll so that the form size automatically increased and causing the behavior in the label control when Anchor to right.

For the other problem, either setting properties through IsIdea or directly I should not be any different. Perhaps you might want to post the problematic code so I can take a look?

Thanks,
David

DavidTSoMSFT at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...
# 2
Well... I have found the issue. I am dynamically added the controls at run time and If I set the (top,left,height,width) properties before I anchor right they do not persist. They get reset to 0's. If I anchor left they do persist.

I may check this out in reflector, but to me it looks buggish. I am doing a CF2 smartphone app. (does anyone see the same behavior?). The work around is to load/reload the properties after the right or bottom anchor.

AllenAlper at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...