仅在选定的面板中触发c# [英] trigger only in the selected panel c#

查看:81
本文介绍了仅在选定的面板中触发c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友..



i正在做一个项目,我需要一些帮助



这就是我分别有两个面板..当我点击事件时它会显示在两个面板中..



但是我希望它显示在专注小组或选定小组



这里是我的代码..

它试过这个



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..

推荐答案

你想在面板聚焦时显示东西吗?

那么你可以使用GotFocus事件处理程序。



例如



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

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



private void Panel1Selected(object sender,EventArgs e)

{

// panel1显示员工...

}



private void Panel2Selected(object sender,EventArgs e)

{

//面板2显示员工......

}
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...
}


这篇关于仅在选定的面板中触发c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆