WinForm获取控件在屏幕上的坐标

JanWarlen 2015-11-17 10:01:56
面板有多层panel控件在最上面一层,控件.Location是相对于父容器的坐标,难不成要.parent.parent....下去直到parent到最底层面板?
...全文
618 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
JanWarlen 2015-11-17
  • 打赏
  • 举报
回复
已解决:
Control control = myButton1;
                Point showPoint = new Point();
                while (control != this)
                {
                    showPoint.X += control.Location.X;
                    showPoint.Y += control.Location.Y;
                    control = control.Parent;
                }

                showPoint.X += control.Location.X;
                showPoint.Y += control.Location.Y;

110,545

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧