praveen kumar

praveen kumar

  • NA
  • 36
  • 21.4k

Changing LinkLabel Text in Mdi Parent

Oct 15 2015 2:18 AM
Hi Every One,
I am New To Windows Form Applications   my requirement,
i open maximum 5 child forms in my mdi parent  what forms  i opened that names should add to link labels i took 5 link labels at my design time it is working fine my problem is when i opend 5 forms and close forms order 5,4,3,2,1 lits working but when i close 3 rd child form and add one more child its not coming properly  and what i want when create linklabel 2 or any thing it will re size its not working i am attached code what i have written .
 
i Created my own method CallMenu() and Add to every toolstripmenuitem_Click()Event
public void CallMenu()
{
if (MdiChildren.Count()<6)
{
if (MdiChildren.Count() == 1)
{
linkLabel1.Text = this.ActiveMdiChild.Text;
linkLabel1.Visible = true;
}
else if (MdiChildren.Count() == 2)
{
llinkLabel2.Text = this.ActiveMdiChild.Text;
linkLabel2.Visible = true;
}
else if (MdiChildren.Count() == 3)
{
lnk3.Text = this.ActiveMdiChild.Text;
lnk3.Visible = true;
}
else if (MdiChildren.Count() == 4)
{
linkLabel4.Text = this.ActiveMdiChild.Text;
linkLabel4.Visible = true;
}
else if (MdiChildren.Count() == 5)
{
linkLabel5.Text = this.ActiveMdiChild.Text;
linkLabel5.Visible = true;
}
}
 When I Close The Child Form  this close i event also write in ToolStripmenuitemClick_Event
private void frm_FormClosed(object sender, FormClosedEventArgs e)
{
Form fr = (Form)sender;
if (fr.Text == linkLabel1.Text)
{
llinkLabel1.Visible = false;
}
else if (fr.Text == linkLabel2.Text)
{
linkLabel2.Visible = false;
}
else if (fr.Text == linkLabel3.Text)
{
linkLabel3.Visible = false;
}
else if (fr.Text == linkLabel4.Text)
{
linkLabel4.Visible = false;
}
else if (fr.Text == linkLabel5.Text)
{
linkLabel45.Visible = false;
}
}
 
If any one knows please replay me,
Thank you in Advance.