我想请问一下如下情况怎么解决:
     有一个主窗体,若干个子窗体(通过点击主窗体中mainmenu调出),我想要让这些子窗体只能固定在主窗体的某个区域(这些子窗体是已经设计好了的类似与主窗体的窗体,即独立的模块),请问有没有办法解决这个问题!谢谢

解决方案 »

  1.   

    form2.Dock(form1.Panel1,panel1.ClientRect);//建议使用停靠
      

  2.   

    能不能说得具体点,我没看到有Dock这个方法
      

  3.   

    Form.Dock(公共属性)(从 Control 继承)获取或设置控件停靠到父容器的哪一个边缘。
    下面例子虽然是控件停靠,但用法是一样的。private void AddMyGroupBox()
    {
       // Create a GroupBox and add a TextBox to it.
       GroupBox groupBox1 = new GroupBox();
       TextBox textBox1 = new TextBox();
       textBox1.Location = new Point(15, 15);
       groupBox1.Controls.Add(textBox1);   // Set the Text and Dock properties of the GroupBox.
       groupBox1.Text = "MyGroupBox";
       groupBox1.Dock = DockStyle.Top;   // Disable the GroupBox (which disables all its child controls)
       groupBox1.Enabled = false;   // Add the Groupbox to the form.
       this.Controls.Add(groupBox1);
    }
      

  4.   

    我是这样做的:mainform是主窗口,form1是要停靠的窗口
    在mainform.cs中添加代码:
    Form1 form1 = new Form1();
    this.Controls.Add(f1);
    f1.Dock = DockStyle.Left;运行时提示有错,错误原因为:不能将顶级控件添加到一个控件上。不知道是不是我理解错了44404的意思