我写 txtTemp.Location.X 这是获取在groupbox里面的X坐标
 我想获取在from的X坐标怎么写啊 txtTemp在groupbox里面的。

解决方案 »

  1.   

    Point p=new Point( groupBox.Left+txtTemp.Left, groupBox.Top+txtTemp.Top);
      

  2.   

    Point p=this.PointToClient(txtTemp.PointToScreen(Point.Empty));
    这种更好点
      

  3.   


    如果不知道有多个父容器,就需要遍历....把坐标加起来.....      Point po = new Point(0, 0);
          private void GetCtlLocation(Control ctl,bool )
          {
            if ()
            {
              po = new Point(ctl.Location.X, ctl.Location.Y);
            }
            if (ctl != null)
            {
              if (ctl.Parent != null)
              {
                po.X += ctl.Parent.Location.X;
                po.Y += ctl.Parent.Location.Y;
                GetCtlLocation(ctl.Parent, false);
              }
            }
          }