Thanks everyone, I found the answer on stackoverflow . I am posting here to help the new community members. It's my request to the senior members here to please spare some time to improve the below answer.
Panel P = this.Parent as Panel;
if(P!=null)
{
sale_purchase sp = new sale_purchase();
code.logics.showwindow(sp, this, P);
}
public static void showwindow(Form openwin , Form closewin , Panel p)
{
closewin.Close();
openwin.TopLevel = false;
p.Controls.Add(openwin);
openwin.WindowState = FormWindowState.Maximized;
openwin.ControlBox = false;
openwin.BringToFront();
openwin.Show();
}