本人重写了toolstripcomboBox,点击下拉的时候弹出一个窗体,请问怎样获取toolstripcomboBox相对于屏幕的坐标,使窗体弹出是出现在toolstripcomboBox的下方?

解决方案 »

  1.   

    this.Location 获得主窗口的Point
    toolstripcomboBox.Location 获得该空间相对主窗口的Point
    你要弹出的窗口的Location.X = this.Location.X + toolstripcomboBox.Location.X;
    你要弹出的窗口的Location.Y = this.Location.Y + toolstripcomboBox.Location.Y + toolstripcomboBox.Height;
      

  2.   

    Point p = new Point(0,this.toolstripcomboBox.Height);  //下方
      

  3.   


          Point p = toolstripcomboBox.Location;
          p.Y += toolstripcomboBox.Height;
      

  4.   

    没有这个toolstripcomboBox.Location属性。
      

  5.   

    这应该是你要的吧
    左上角横坐标: toolStripComboBox1.Bounds.X
    左上角纵坐标: toolStripComboBox1.Bounds.Y
    控件高度:     toolStripComboBox1.Height左下角纵坐标: toolStripComboBox1.Bounds.Y + toolStripComboBox1.Height
      

  6.   

    这应该是你要的吧
    左上角横坐标: toolStripComboBox1.Bounds.X
    左上角纵坐标: toolStripComboBox1.Bounds.Y
    控件高度:     toolStripComboBox1.Height左下角纵坐标: toolStripComboBox1.Bounds.Y + toolStripComboBox1.Height
      

  7.   

    谢谢各位,终于解决了这问题。
    //要显示的Form
    Form form=new Form();
    form.StartPosition=FormStartPosition.Manuul;
    Point p=this.Owner.PointToScreen(new Point(this.Bounds.X,this.Bounds.Y));
    form.Location=new Point(p.X,p.Y+this.Size.Height);