转载:点击跳到原作者

        /// <summary>
        /// 获取控件在客户区的坐标,相对于顶级父容器的坐标
        /// </summary>
        /// <param name="c">控件</param>
        /// <returns>坐标点</returns>
        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;
        }
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐