C# WIN程序。我点击textBox把隐藏的panel容器(容器里有复选框)显示出来,现在我要做点击panel容器以外的地方,都要隐藏panel容器。我该怎么做。

解决方案 »

  1.   

    private void textBox1_TextChanged(object sender, System.EventArgs e)
    {
    this.panel1.Hide();
    }
      

  2.   

    panel1的LostFocus事件里面写panel1.Hide();
      

  3.   

    panel1的LostFocus事件里面写
    ---------------------------------
    这个怎么写来着
      

  4.   

    panel1 右键属性 事件  LostFocus 双击LostFocus
    在生成的方法中写panel1.Hide();
      

  5.   

    问题,右键属性 事件  没有LostFocus
      

  6.   


    this.panel1.LostFocus += new System.EventHandler(this.panel1_LostFocus);private void panel1_LostFocus(bject sender, EventArgs e)
    {
        this.panel1.Hide();
    }你试试
      

  7.   

    this.panel1.LostFocus += new System.EventHandler(this.panel1_LostFocus);
    这个这样写要报错的
      

  8.   

    public Form1()
    {
       InitializeComponent();
       this.panel1.LostFocus += new System.EventHandler(this.panel1_LostFocus); 
    }private void panel1_LostFocus(bject sender, EventArgs e)
    {
        this.panel1.Hide();
    }
      

  9.   

    我试了 事件不会被触发
    你可以在点击 所有其他控件的时候, 隐藏这个panel
    这个方法很笨
      

  10.   

    呵呵,简单问题..建议楼主看一下MSDN的相关帮助
      

  11.   

    private void 你的窗口_Load(object sender, EventArgs e)
            {
            this.panel1.Hide();
            }
    就可以了
    你的panel1名字有改的话,也要跟着改名字
      

  12.   

    private void textBox1_Enter(object sender, EventArgs e)
            {
                panel1.Visible = true;
            }        private void textBox1_Leave(object sender, EventArgs e)
            {
                panel1.Visible = false;
            }
      

  13.   

    private void textBox1_Leave(object sender, EventArgs e)
            {
                panel1.Visible = false;
            }
    这个不试过了,不可以的,我没有点过panel1中的复选框就没有作用
      

  14.   

    private void textBox1_Leave(object sender, EventArgs e)
            {
                panel1.Visible = false;
            }
    这个方法当我去点panel1中的复选框,就会不对了
      

  15.   

    确实考虑不周
            public Form1()
            {
                InitializeComponent();
                foreach (Control control in this.Controls)
                {
                    if (control != textBox1 && control != panel1)
                    {
                        control.Enter += GroupInvisible;
                    }
                }
            }
            private void GroupVisible(object sender, EventArgs e)
            {
                panel1.Visible = true;
            }        private void GroupInvisible(object sender, EventArgs e)
            {
                panel1.Visible = false;
            }