开发者

Panel moving after visibility changing

Using WinForms and C#:

I have a panel that contains a groupbox, some checkboxes, and textboxes. This panel is not always visible. Depending on user selections I show the panel. However, the screen is large enough that it requires scrollbars depending on your screen resolution.

Does anyone know why the panel would move based on the AutoScrollPosition? I cannot find why it jumps around. I am not changing the location anywhere in the code. I have found a work around that I have listed below. But it would be nice to understand why it is happening.

        开发者_StackOverflow社区   if (m_PanelHoist.Location.Y != m_GroupBoxDrag.Location.Y)
           {
              Point point = m_PanelHoist.Location;
              point.X += AutoScrollPosition.X;
              point.Y += AutoScrollPosition.Y;
              m_PanelHoist.Location = point;
           }


You are using this.AutoScrollPosition. Which suggests that the panel is getting scrolled by the form. That's entirely normal, all child controls inside the form are subject to getting scrolled, including your panel. Your code snippet indeed compensates for that.

By design.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜