Panel.Dock Fill ignoring other Panel.Dock setting

后端 未结 10 1077
我寻月下人不归
我寻月下人不归 2020-12-04 06:02

If you create a panel on a form and set it to Dock=Top and drop another panel and set its Dock=Fill, it may fill the entire form, ignoring the first panel. Changing the tab

10条回答
  •  时光取名叫无心
    2020-12-04 06:31

    I ran into the same issue. Mine was with adding new/custom controls below the menu strip during run time. The problem was the controls when docked, decided to dock from the top of the form and completely ignoring the menu strip entirely, very annoying if you ask me. As this had to be done dynamically with code and not during design mode this became extremely frustrating. The simplest way I found is to create a panel during design mode and dock below the menu strip. From there you can just add/remove the controls to the panel and you can dock it during run time. No need to mess with all your controls on your form that do not really need to change, too much work depending on what you really need to do.

    object.dock = Fill
    Panel.Controls.Add(object)
    

提交回复
热议问题