简体   繁体   中英

Cannot select text of TextBox control with mouse

I want to embed a Form within another Form . Here is what I have tried:

private void Form1_Load(object sender, EventArgs e)
{
    Form2 form = new Form2();  
    form.TopLevel = false;  
    panel1.Controls.Add(form);  
    form.Dock = DockStyle.Fill;  
    form.Show();  
}

Form1 is the parent form. Form2 is the child form, which has a TextBox control.

The problem: After embedding the child form, the TextBox in the child form cannot be selected with the mouse.

Can anyone help?

I Googled the problem. From my research I concluded that it's not a good idea to embed a Form within a Panel . I took another approach and have now made the child Form as an MDI child.

You need to setup the parent of the Form before calling .Show()

form.Parent = this;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM