本帖最后由 jshzp 于 2011-07-17 12:14:04 编辑

解决方案 »

  1.   

    弹出每个窗体的时候,设置他们各自的top,left,height,width值,让他们靠在一起
      

  2.   

    如果想让这两个窗体总在最前端显示,可以设置topmost属性为true
      

  3.   

    比如这样:2个Form,一个叫FormA,一个叫FormB。为了让FormB始终紧靠FormA的右侧。则映射FormB的Activated、SizeChanged事件,在其中设置FormB的Location属性,使其与FormA的右上角坐标一致。同时,在FormA被激活或窗口大小改变时,也调整FormB的Location。
      

  4.   

    看来在顶楼我没有把问题说清楚,f1和f2是“重叠着的",f1在f2之下,而f2是置顶的。不是楼上说的那个意思。
      

  5.   

    在 Form1 里面写:
    Form2 f2 = new Form2();
    f2.Show(this);
      

  6.   

    就是控制MDI中子窗口的Z轴顺序吧。以前Win32编程,有个SetWindowPos()的API。不知道现在.NET里有没对应的函数封装。
      

  7.   

    查了一下MSDN,Form类有TopLevel和TopMost属性。
      

  8.   


    /// <summary>
            /// 主窗口的Load...
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void DiaryFrm_Load(object sender, EventArgs e)
            {     
               // 用以下的事件,确保窗口移动的时候子窗口跟随主窗口     
    this.LocationChanged += new EventHandler(DiaryFrm_LocationChanged);
                this.SizeChanged += new EventHandler(DiaryFrm_SizeChanged);                     //弹出两个窗口,紧靠着主窗口右侧                         
                this.m_ifrm.Location = new Point(this.Location.X + this.Width, this.Location.Y);
                this.m_ifrm.Owner = this;
                this.m_ifrm.Show();            this.m_ifrm1.Location = new Point(this.Location.X + this.Width, this.Location.Y + this.m_ifrm.Height);            
                this.m_ifrm1.Owner = this;            
                this.m_ifrm1.Show();
    }/// <summary>
            /// Size Changed
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void DiaryFrm_SizeChanged(object sender, EventArgs e)
            {
                if (this.WindowState == FormWindowState.Minimized)
                {
                    
                    
                }
                else
                if (this.WindowState == FormWindowState.Maximized)
                {
                    
                    this.m_ifrm.Location = new Point((this.Location.X + this.Width) - this.m_ifrm.Width - 20, this.Location.Y + SystemInformation.CaptionHeight + SystemInformation.ToolWindowCaptionHeight);                
                    this.m_ifrm1.Location = new Point((this.Location.X + this.Width) - this.m_ifrm.Width - 20, this.Location.Y + this.m_ifrm.Height + SystemInformation.CaptionHeight + SystemInformation.ToolWindowCaptionHeight);
                }
                else
                {
                    
                    this.m_ifrm.Location = new Point(this.Location.X + this.Width, this.Location.Y);                
                    this.m_ifrm1.Location = new Point(this.Location.X + this.Width, this.Location.Y + this.m_ifrm.Height);
                }
            }        /// <summary>
            /// Location Changed
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void DiaryFrm_LocationChanged(object sender, EventArgs e)
            {
                if (this.WindowState != FormWindowState.Maximized)
                {
                    this.m_ifrm.Location = new Point(this.Location.X + this.Width, this.Location.Y);
                    this.m_ifrm1.Location = new Point(this.Location.X + this.Width, this.Location.Y + this.m_ifrm.Height);
                }
            }