C#: Anchored Panel won't resize properly

后端 未结 3 1306
有刺的猬
有刺的猬 2021-02-05 06:10

I\'ve a strange problem regarding auto sizing of a panel in a user control. This panel is anchored to all 4 sides of the user control. But the anchoring not always works as it s

相关标签:
3条回答
  • 2021-02-05 06:56

    The problem is not the depth of nesting; controls can be nested arbitrarily deep. Anchoring and Docking generally do not play nicely with each other. I usually favor docking over anchoring, but, whichever solution you choose, you should probably avoid mixing them.

    0 讨论(0)
  • 2021-02-05 06:57

    There is a bug with deep nesting where the kernel runs out of stack space causing resizing, docking and anchoring to fail silently.

    See https://web.archive.org/web/20140818095718/http://support.microsoft.com/kb/953934

    0 讨论(0)
  • 2021-02-05 07:10

    You have talked about both "anchor" and "dock", which can serve similar purposes but act differently. Your problem may be that you are trying to do both, and this is interfering with the behavior you want. If not, perhaps try switching from the one to the other.

    It sounds like you've double checked the ansectery of the control, but did you examine it with: View->Other Windows->Document Outline (a very handy tool I only recently discovered)?

    Finally, while it doesn't directly solve your problem, it sounds like you have a very complicated UI, and your users may benefit if you were to spend some time to consider if you could simplify the UI. Of course, I don't know your users or the purpose of the app, and what you have may be the best, but it sounds like it might be time to ask this question.

    Good luck.

    0 讨论(0)
提交回复
热议问题