如何实现子窗体跟随父窗体一起移动?
1个回答
展开全部
在主窗体上产生一个子窗体,父窗体有标题栏,在移动父窗体时如何让子窗体跟随父窗体一起移动,相对位置移动前后相同; public Tool() { InitializeComponent(); } #region[私有变量] Main MFrom { set; get; } private Point _parentPoint, _basePoint,ItemPoint,StartPoint,EndPoint; private int _MoveWidth = 25; private bool _adsorb; //是否吸附 #endregion public Tool(Main parent) { InitializeComponent(); MFrom = parent; this.Location = new Point(parent.Location.X, parent.Location.Y + MFrom.Height - this.Height - MFrom.statusBar1.Height); MFrom.LocationChanged +=new EventHandler(MFrom_LocationChanged); this.LocationChanged +=new EventHandler(Tool_LocationChanged); this._toolBar.ButtonClick+=new ToolBarButtonClickEventHandler(_toolBar_ButtonClick); } /// /// 父窗体移动带动子窗体 /// /// /// private void MFrom_LocationChanged(object sender, EventArgs e) { //? } /// /// 子窗体移动吸附 /// /// /// private void Tool_LocationChanged(object sender, EventArgs e) { _basePoint = this.Location; _parentPoint = MFrom.Location; ItemPoint = MFrom.PointToScreen(MFrom.toolBar1.Location); if (_parentPoint.X - _basePoint.X
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询