1
votes

I've got this strange issue I've never encountered before. I've done a bunch of searching online and have found people with the same issue, but no proper fixes (at least none that I can find).

Basically, I have a C# WinForm application launches child forms and adds them to the controls of the main form (so rather than the child forms launching as a separate window, they launch within the main application window).

The strange behaviour is that any TextBox controls on the child forms don't accept any mouse input. If I try to click in the TextBox to put the cursor at a specific point in the text, the cursor always goes to the first character. I can move around using the keyboard, but not with the mouse.

I have set the main form as an MDI Container (this.IsMdiContainer = true) and have also set the parameters of the child form correctly:

childForm.TopLevel = false;
childForm.AutoScroll = true;
childform.Parent = parentForm;
parentForm.Controls.Add(childForm);

I initially had the childForm loading inside a panel, but removed the panel as there's no IsMdiContainer parameter for a panel control, but loading it inside the main form doesn't seem to work either. Weird, man. Weird.

Any hints?

1
and have also set the parameters of the child form correctly: If childForm is an mdi child, you have to set the childForm.MdiParent property. MDI child forms require a normal sizable border, too.LarsTech
Thanks mate. We always miss the little things, huh? :)Benny O'Neill

1 Answers

1
votes

Its not Parent, its MDIParent:

childForm.MdiParent = this; //(or parentForm)