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.

Re: Resizing Controls that are contained in a docked Control by John

John
Mon Sep 18 22:16:12 CDT 2006

illegal.prime@gmail.com wrote:
> 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.ba
> 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.
>

I dont quite follow what the problem is here.

You are setting the dockstyle of the label to top which should (and
does) suppress any width changes except those triggered by the resize of
the parent (panel1).

The Height is able to be changed just fine (at least in my sample).

Bear in mind also the autosize property of the label is true by default.

Multiple top docked controls appear to be cascaded too.

If you need to have a 'docked' control that does not span the whole
width/height then use the anchor property instead.

JB

Re: Resizing Controls that are contained in a docked Control by Cor

Cor
Mon Sep 18 23:59:22 CDT 2006

Hi,

If I understand you well, than have a look at the anchor properties.

Cor

<illegal.prime@gmail.com> schreef in bericht
news:1158632465.244208.68270@m7g2000cwm.googlegroups.com...
> 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.
>