Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
849
AutoSize for controls inside a WinGridBagLayoutPanel
posted

Hello,

I have a pretty standard layout in a WinGridBagLayoutPanel: 1 column for labels, 1 column for editor controls (textboxes, grids...). My application supports different languages so what I want is the width of the label column to adjust to the content of the labels (French texts are usually longer than English ones).

What I have tried to do is set the AutoSize property on my UltraLabels to true, thinking naively that if they get wider than the column, they would "request" more space to the WinGridBagLayoutPanel. But this does not seem to be the case...

Is there a way to achieve that?

Thanks,

Damien

Parents
  • 469350
    Verified Answer
    Offline posted

    Hi Damien,

    I tried to test this out, but it's tough to do without knowing all of the settings you are using. There are too many variables.

    My guess is that something you have done up to this point has caused the PreferredSize on the GridBagLayout for the labels to have already been established and so the AutoSize or PreferredSize on the control itself is getting overriden. So this might be a simple matter of resetting the PreferredSize for each of the labels:

    this.ultraGridBagLayoutPanel1.ResetPreferredSize(this.ultraLabel1);

Reply Children
No Data