1、步骤1,有个功能是新建窗体,富文本停靠在窗体上,代码如下
    Form fm = new Form();
            fm.Location = new Point(0, 0);
            fm.TopMost = true;
            fm.MdiParent = this;
            fm.AutoScroll = true;
            fm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            RichTextBox rt = new RichTextBox();
            rt.Dock = System.Windows.Forms.DockStyle.Fill;
            rt.Location = new Point(0, 0);
            rt.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
            rt.ReadOnly = true;
            rt.BackColor = System.Drawing.Color.White;
            fm.Controls.Add(rt);
            fm.Show();
2、在新建的窗体,里面动态添加文本框,代码如下:
 int name = new DateTime().Millisecond;
            TextBox txtBox = new TextBox();
            txtBox.Name = "txt" + name;
            txtBox.Multiline = true;
            txtBox.Size = new System.Drawing.Size(100, 25);
            txtBox.BorderStyle = BorderStyle.FixedSingle;
            txtBox.Location = new Point(25 + count, 20 + count);
            Form activeForm=this.ActiveMdiChild;//获取被激活的窗体
            foreach(Control crl in activeForm.Controls)
            {
                if(crl is RichTextBox)
                {
                    crl.Controls.Add(txtBox);
                }
            }
            count += 10;3、遍历这个窗体里面的控件代码如下,请问为什么只能找出一个来(这里我动态添加了10个文本框)
Form activeForm = this.ActiveMdiChild;
 foreach (Control crl in activeForm.Controls)
{}
//activeForm.Controls.count只有一个的?