我做了一个自定义控件,有一个button,textbox,和一个form   点击一个button form弹出 刚好停靠在textbox的下面 但是当我把控件拖到panel 上 form的位置并不能 停靠在textbox的下面    

解决方案 »

  1.   

       具体怎么设置?
    form.StartPosition = FormStartPosition.Manual;
    form.Location = new Point(this.Parent.Location.X + this.Left + 4, this.Parent.Location.Y + this.Top + this.Height + 30);
    我是这样设置的 
    但会出现上面我说的那种问题
      

  2.   

    控件在panel上的时候可能this.parent不是控件本身,你show这个form时候指定一下
      

  3.   

    我自己解决了
      if (this.Parent.Parent == null)
                {
                    form.Location = new Point(this.Parent.Location.X + this.Left + 4, this.Parent.Location.Y + this.Top + this.Height + 30);
                }
                else
                {
                    form.Location = new Point(this.Parent.Parent.Location.X + this.Parent.Left+this.Left + 4, this.Parent.Parent.Location.Y   +this.Parent.Top+ this.Top + this.Height + 30);
                }