C# 获取控件在客户区的坐标,相对于顶级父容器的坐标

转载:点击跳到原作者

        /// 
        /// 获取控件在客户区的坐标,相对于顶级父容器的坐标
        /// 
        /// 控件
        /// 坐标点
        public static Point LocationOnClient(Control c)
        {
            var retval = new Point(0, 0);
            for (; c.Parent != null; c = c.Parent)
            {
                retval.Offset(c.Location);
            }
            return retval;
        }

你可能感兴趣的:(C#开发工作笔记)