suppose i have have two sdi form and when apps run then a sdi form show and from there i am showing another sdi form but the problem is i can drga any where the second sdi form which i do not want. in case of MDI form the mdi child form can not be drag out of mdi form boundary.so in my case i want to simulate the same thing. i want no other sdi form can not be drag out form my main sdi form's boundary. so just guide me how to do this.
i could guess that i have to work with form drag event and from there i have to check form top and left but need more suggestion.
privatevoidForm1_Move(object sender,EventArgs e){this.Location= defaultLocation;}
i try to do it this way but it is not working.
publicpartialclassForm2:Form{Form1 _parent =null;publicForm2(){InitializeComponent();}publicForm2(Form1 parent){InitializeComponent();
_parent = parent;}privatevoidForm2_Move(object sender,EventArgs e){if((this.Location.X+this.Width)> _parent.Width){this.Location=newSystem.Drawing.Point(_parent.ClientRectangle.Width-this.Width,this.Location.Y);}if((this.Location.Y +this.Height)> _parent.Height){this.Location=newSystem.Drawing.Point(_parent.ClientRectangle.Height-this.Height,this.Location.X);}if(this.Location.Y <0){this.Location=newSystem.Drawing.Point(this.Location.X);}if(this.Location.X <0){this.Location=newSystem.Drawing.Point(this.Location.Y);}}}
please guide me where i made the mistake. thanks