Mohsen K
Mohsen K

Reputation: 287

move parent form when child form moves in c# winforms

ok , i searched but didnt find what i want so far...

i have a main form and another form named RadEditTemplate.. i ShowDialog() the edit form like this :

 new RadEditTemplate().ShowDialog();

i made the RadEditTemplate form the same size as the main form and made it center.

i want to lock these forms together so when i move the editform the main form move with it as well.
i have seen this in Winscp app before. how can i do this ?

Upvotes: 1

Views: 786

Answers (1)

Adam Klon
Adam Klon

Reputation: 46

In MainForm:

Form RadEditTemplate = new Form();
RadEditTemplate.Move+=On_Move;
RadEditTemplate.ShowDialog();

void On_Move(object sender, EventArgs e)
{
this.Location = new Point(((Form)sender).Location.X, ((Form)sender).Location.Y);
}

Upvotes: 2

Related Questions