D
David Veeneman
I think I may have stumbled across a bug in Visual Studio 2005, .NET 2.0, or
both. The Anchor property doesn't seem to work if a form's size is bound to
a user setting.
To reproduce the problem:
1. Create a Windows Forms application.
2. Add a label to Form1. Change the background color of the label to a color
that contrasts with the form. I used red. Resize the label so that it fills
Form1.
4. Set the label's Anchor property to Top, Left, Right, Bottom.
5. In the Properties window for Form1, under '(ApplicationSettings)', click
the '(PropertyBinding' elipsis and create a new binding for the ClientSize
property.
6. Create an event handler for Form1's FormClosing event and add a call to
Settings.Default.Save() to the handler.
7. Run the app. The label should fill the form. Resize the app. The label
should grow with the form. Close the app.
8. Restart the app. The label will no longer fill the form. It will still
hold its original size.
The problem doesn't occur with docked controls. As a workaround, I am
docking whenever I can. If I have to anchor, I am binding the size property
to a user setting, so that it will remember its size from session to
session.
both. The Anchor property doesn't seem to work if a form's size is bound to
a user setting.
To reproduce the problem:
1. Create a Windows Forms application.
2. Add a label to Form1. Change the background color of the label to a color
that contrasts with the form. I used red. Resize the label so that it fills
Form1.
4. Set the label's Anchor property to Top, Left, Right, Bottom.
5. In the Properties window for Form1, under '(ApplicationSettings)', click
the '(PropertyBinding' elipsis and create a new binding for the ClientSize
property.
6. Create an event handler for Form1's FormClosing event and add a call to
Settings.Default.Save() to the handler.
7. Run the app. The label should fill the form. Resize the app. The label
should grow with the form. Close the app.
8. Restart the app. The label will no longer fill the form. It will still
hold its original size.
The problem doesn't occur with docked controls. As a workaround, I am
docking whenever I can. If I have to anchor, I am binding the size property
to a user setting, so that it will remember its size from session to
session.