I'm surprised that I'm only know discovering this problem, but I
suppose I've never needed to change the dimension that is opposite to
the docking of the control. That is, when I've docked a control to
Top, I've never needed to change its height and vice-versa. But, now I
would like to do this and I'm not sure what the "right way" is to
perform this.
Should I just add an extra container (panel, usercontrol, etc) around
the control whose dimension I want to change. For example, if I have a
UserControl whose width I would like to set manually and which happens
to be set to Dock to Top. Should I just house it in another
UserControl/Panel/Etc and then not Dock it in that container?
Thanks,
Novice
PS If my problem is not abundantly clear - create a windows
application, Add a Panel to your Form, then in the Contructor - put
this:
for (int i = 0;i < 50; i++)
{
Label label = new Label();
label.Dock = DockStyle.Top;
label.Text = "MyTextMyTextMyTextMyTextMyTextMyTextMyText" + i;
label.Width = 1000;
label.Height = 1000;
//label.Size = new Size(1000,300);
panel1.Controls.Add(label);
}
for (int i = 0;i < panel1.Controls.Count;i++)
{
Console.Out.WriteLine("control width: "+panel1.Controls[i].Width+"
control height: "+panel1.Controls[i].Height);
}
Then notice how the controls all get set to a height and width of 1000.
Then try changing the panel1 to be docked - either to Fill or just one
side and you'll see how the dimension changes you try to make will be
suppressed.