A short preliminary note: there are not parent-child relationships between forms. (I don't mean MDI parent and children, which is not the same thing, also, who needs MDI? :-)) There are owner and owned forms though; I would highly recommend to have all forms owned by the main form which helps application integrity.
Now, about preventing form dragging. Weird enough, this is ridiculously simple to achieve:
- Add the following code to the the form constructor:
public NonMovableForm() {
InitializeComponent();
this.ControlBox = false;
this.Text = null;
}
If you want to do the same for a non-main form, I would highly recommend to add ShowInTaskbar = false
.
- If you really need it, create a fake control imitating a title bar with Close button on it (or not) and dock it to the top of the form.
- Do not implement form dragging. :-)
- Get ready to receive multiple complaints from the users.
- PROFIT? I'm not sure — see the item above.
Anyway, the problem is solved. Decide for yourself if you really want it.
—SA