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
Hi Mike,
I tried to call ResetPreferredSize after setting the text on my label and it works! :-)
I have tried several things afterwards to try and understand if I did something wrong. I'm not sure if I get everything right, but here is what I need to do to get it to work: in the code, I need to call ResetPreferredSize on one of the labels and then all following changes to any label will call a proper resize of the column... It is a bit weird, but that's what I get... If you want my small sample, I can send it.
In any case, thanks for the quick and brilliant answer! ;-)
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);