Anchors, MinSize, and AutoScroll
-
I have a situation where I have a panel inside another panel (we'll call them innerPanel and outerPanel). outerPanel is anchored on all four sides so it expands and contracts with the window. outerPanel also has the AutoScroll property set to true. If I put innerPanel inside outerPanel and anchor it left, right, and top then when I make the window very short scroll bars appear on outerPanel. However, innerPanel's height will not expand when I expand the window. This is what I expect to happen. If I set the anchors on innerPanel to all four sides it expands and contracts with the window. However, sometimes innerPanel shrinks too small to see it's contents. This is the behavior I expect. Now, if I set a minimum width on innerPanel and anchor to all four sides it will expand with the window like I want, but when I reach that minimum size innerPanel just gets cut off, the scroll bars never appear. This is absolutely not what I expect. Am I doing something wrong? I want innerPanel to expand freely in all directions and contract to a minimum size, then if it's container is too small for innerPanel I want scroll bars to appear. Obviously the simple solution here is to set AutoScroll to true on innerPanel and anchor it to all four sides, but in my real application there are several innerPanels and it would look ridiculous to have seven scroll bars on the page. Thank you in advance.
-
I have a situation where I have a panel inside another panel (we'll call them innerPanel and outerPanel). outerPanel is anchored on all four sides so it expands and contracts with the window. outerPanel also has the AutoScroll property set to true. If I put innerPanel inside outerPanel and anchor it left, right, and top then when I make the window very short scroll bars appear on outerPanel. However, innerPanel's height will not expand when I expand the window. This is what I expect to happen. If I set the anchors on innerPanel to all four sides it expands and contracts with the window. However, sometimes innerPanel shrinks too small to see it's contents. This is the behavior I expect. Now, if I set a minimum width on innerPanel and anchor to all four sides it will expand with the window like I want, but when I reach that minimum size innerPanel just gets cut off, the scroll bars never appear. This is absolutely not what I expect. Am I doing something wrong? I want innerPanel to expand freely in all directions and contract to a minimum size, then if it's container is too small for innerPanel I want scroll bars to appear. Obviously the simple solution here is to set AutoScroll to true on innerPanel and anchor it to all four sides, but in my real application there are several innerPanels and it would look ridiculous to have seven scroll bars on the page. Thank you in advance.
Hi, if anchors, docking, autosize and what have you, don't perform as you would like them to, there is a straightforward solution: don't use them at all, and write some code instead, in the OnResize method of the relevant panels. That's what I used to do from day one, until I discovered some cases (particularly the simple ones) could be solved by setting anchors and so. The advantage is you can make it do whatever you can come up, you don't have to fight the built-in functionality, not even read the documentation... :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
Hi, if anchors, docking, autosize and what have you, don't perform as you would like them to, there is a straightforward solution: don't use them at all, and write some code instead, in the OnResize method of the relevant panels. That's what I used to do from day one, until I discovered some cases (particularly the simple ones) could be solved by setting anchors and so. The advantage is you can make it do whatever you can come up, you don't have to fight the built-in functionality, not even read the documentation... :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
Thanks for the reply. I figured that is what I would end up needing to do, but I wanted to see if anyone had other ideas. Anchors do what I need them to do 90% of the time so it's frustrating when they don't do what I want :p