I have a label and a textbox in my Winform. They are one line.
What I want to do is to make the textbox always fill-in the available space between the label and the right border of the container, even when window is resized
The label is set to be AutoSize because it has different width in different languages.
I tried the flow layout, and I also tried various combinations of dock/anchor in both elements, but still can't make it work. If there is not simple solution (beside program coding resizing myself), is there a less optimal solution? Thanks.
if it's only those 2 elements that need to be auto-layouted try this:
take a table layout panel with 2 columns and one row ... your label goes in one cell, the textbox in the other ... dock both elements (dock fill) and set the column the label is in to autosize
dock the whole panel to whatever element you want (probably your form)
you may want to add some padding to your label
I would put the controls in a panel. Set the panel to the appropiate height. Set the label to autosize and dock it left. Set the textbox dock to fill.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With