Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends..

i am doing a project and in that i need some help

that is i am having two panels separately .. and when i click the event it is displayed in the both panels ..

but i want it to be displayed in the focused panel or selected panel

here goes my code..
it tried this

if(panel1.focused)
      {
        panel1 displaying stuff..
        }
      else if (panel2.focused)
     {
      panel2 displaying stuff
        }

but no use ...

here is the original code
    if(splitContainer1.Panel1.focused)
   {
  splitContainer1.Panel1.Controls.Clear();
    Label lbl = (Label)sender;

    OpenFile(@" " + lbl.Text);
    var a = new DisplayForm(_file);
    a.TopLevel = false;
    a.Visible = true;
    a.Dock = DockStyle.Fill;
    a.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    splitContainer1.Panel1.Controls.Add(a);
}
 else if(splitContainer1.Panel2.focused)
{
    splitContainer1.Panel2.Controls.Clear();
    Label lbl = (Label)sender;
    OpenFile(@" " + lbl.Text);
    var b = new DisplayForm(_file);
    b.TopLevel = false;
    b.Visible = true;
    b.Dock = DockStyle.Fill;
    b.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    splitContainer1.Panel2.Controls.Add(b);
}


please help me to solve this.. thank you..
Posted

1 solution

Hi, do you wanna do displaying stuff when a panel gets focused?
Then you can use GotFocus event handler.

For example

spiltContainer1.Panel1.GotFocus += new EventHanlder(Panel1Selected);
spiltContainer1.Panel2.GotFocus += new EventHanlder(Panel2Selected);

private void Panel1Selected(object sender, EventArgs e)
{
// panel1 displaying staff...
}

private void Panel2Selected(object sender, EventArgs e)
{
// panel2 displaying staff...
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900