代码之家  ›  专栏  ›  技术社区  ›  Developer

如何隐藏工具提示

  •  1
  • Developer  · 技术社区  · 14 年前

    alt text

    现在,如果我从树中选择第二个节点,仍然会显示工具提示,我想隐藏这些提示

    alt text

    需要帮忙吗


    我的RASINGERROR工具提示代码如下所示

       public class TestClass
        {
            public void RequiredText(TextBox txtTemp, ToolTip newtoolTip)
            {
    
                if (txtTemp.Text != string.Empty)
                {
                    txtTemp.BackColor = System.Drawing.Color.White;
                    newtoolTip.Hide(txtTemp);
    
                }
                else
                {
                    txtTemp.BackColor = System.Drawing.Color.Tomato;
                    newtoolTip.Show("Required", txtTemp);
                }
            }
        }
    

    但这是在使用控制表中完成的。

    3 回复  |  直到 5 年前
        1
  •  1
  •   Hans Passant    14 年前

        private UserControl currentView;
    
        public void SelectView(UserControl view) {
            if (currentView == view) return;
            if (currentView != null) currentView.Dispose();
            if (view != null) this.Controls.Add(view);
            currentView = view;
        }
    

    并从TreeView的AfterSelect事件处理程序中调用SelectView()。

        3
  •  0
  •   Developer    14 年前

    得到的答案是刚刚为每个用户控件编写的Usrcntrl\u Leave事件

        private void usrcntrlPPD_Leave(object sender, EventArgs e)
        {
            this.Dispose();
        }
    

    这解决了我的问题:)