How to solve the problem of panel overlap in WinForm in C #


The overlap of panels in WinForm in C # cannot be displayed

Recently, the development of a project has a requirement that multiple modes need to be switched back and forth. Originally, we considered using multiple windows to realize this function. However, this is a waste of resources and heavy workload, so we thought of using panel control to solve this problem. But in this process, there is a problem. When multiple panel controls overlap, some of the contents in the panel control can not be displayed. At the beginning, it is thought that I deleted the panel control by my own hand. But in the code, the compiler which failed to display the code was not compiled at compile time. So you can be sure that you didn’t delete the control. Finally, I found that the level of control in c#winform was wrong, so I gave the following solution.


First, find out the missing control, open the control window in vs2017, click View > Other windows > document outline, and click to open the document outline. As shown in the figure below:

In the document outline, we can see all the controls in the form. What you need to do now is drag the controls you need to the corresponding level, and then regenerate the solution, as shown in the following figure:

In the use of multi-layer control overlap, it is easy to have the above problems, if the accuracy requirements are not high, you can make a little stagger between the controls, so as to avoid such problems, you can also set the control to several overlaps of different sizes, the method depends on the needs.

The above is the method I give. I hope it can help you. If you encounter the same problem or you have a better solution, I hope you can leave me a message. I also hope you can support developeppaer