R
rrossney
I'm building a UserControl that contains a number of other controls
that it creates and lays out at runtime. I've been messing about
quite a bit with containers and docking and anchoring, and I can't get
it to do exactly what I want it to do. What I want it to do seems
like it would be a pretty common use case, but no amount of searching
has found what I'm looking for. Perhaps someone here can give me a
pointer.
My control takes a list of names and values and lays out a linear
sequence of corresponding Label and TextBox controls. The best
version of it that I've come up with to date positions the controls
from left to right by docking them inside a Panel.
That controls horizontal layout. But the vertical positioning of the
controls stinks: the docked controls are laid out with their tops
aligned to each other, which looks unfortunate at small font sizes and
ugly as sin at large ones.
What I'd ideally like to do is lay out the labels so that their bottom
edge is lined up with the TextBoxes' horizontal snapline. But the
snapline doesn't seem to be accessible at runtime. So my first
question is: am I mistaken? Is there a way of getting a control's
snapline at runtime?
Just to make matters more complicated, I'd like to make my control
incorporate a FlowLayoutPanel, so that if there are too many Label/
TextBox pairs to lay out in the horizontal space available, they'll
wrap without my having to do much programming. To make *this* work, I
think that I need to set things up so that all of the controls I'm
laying out have the same height, which means calculating margins and/
or padding based on the Font that the controls are using.
I can, eventually, figure all of this out, I'm sure. But someone has
to have already solved this problem. I'd appreciate any pointers that
anyone can give me to prior work on this subject.
Thanks in advance,
Bob Rossney
(e-mail address removed)
that it creates and lays out at runtime. I've been messing about
quite a bit with containers and docking and anchoring, and I can't get
it to do exactly what I want it to do. What I want it to do seems
like it would be a pretty common use case, but no amount of searching
has found what I'm looking for. Perhaps someone here can give me a
pointer.
My control takes a list of names and values and lays out a linear
sequence of corresponding Label and TextBox controls. The best
version of it that I've come up with to date positions the controls
from left to right by docking them inside a Panel.
That controls horizontal layout. But the vertical positioning of the
controls stinks: the docked controls are laid out with their tops
aligned to each other, which looks unfortunate at small font sizes and
ugly as sin at large ones.
What I'd ideally like to do is lay out the labels so that their bottom
edge is lined up with the TextBoxes' horizontal snapline. But the
snapline doesn't seem to be accessible at runtime. So my first
question is: am I mistaken? Is there a way of getting a control's
snapline at runtime?
Just to make matters more complicated, I'd like to make my control
incorporate a FlowLayoutPanel, so that if there are too many Label/
TextBox pairs to lay out in the horizontal space available, they'll
wrap without my having to do much programming. To make *this* work, I
think that I need to set things up so that all of the controls I'm
laying out have the same height, which means calculating margins and/
or padding based on the Font that the controls are using.
I can, eventually, figure all of this out, I'm sure. But someone has
to have already solved this problem. I'd appreciate any pointers that
anyone can give me to prior work on this subject.
Thanks in advance,
Bob Rossney
(e-mail address removed)