簡體   English   中英

如何隱藏工具提示

[英]How to hide the tool tips

我有一個帶有一些節點的樹視圖。 我也有一個面板。 我已經采用了一些用戶控件表單,當從子引擎中選擇相應的節點時,我將加載這些用戶控件。 現在我需要的是進行一些驗證,例如如果我將文本框留空,我將向用戶顯示一些工具提示。 假設如果我點擊第一個節點,我將加載一個用戶控件。 如果我點擊確定不提供任何值,我將有一些工具提示如下替代文字

現在,如果我從樹中選擇第二個節點仍然顯示工具提示,我想隱藏那些

替代文字

任何幫助請


我的 rasing error tooltips 代碼如下所示

   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);
            }
        }
    }

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

我還沒有從屏幕截圖中掌握逆向工程代碼的藝術。 我猜您在選擇新控件時不會處理以前的用戶控件。 允許工具提示保持可見。 使用這樣的代碼:

    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()。

您是否嘗試過隱藏方法?

http://dotnetperls.com/tooltip

得到了剛剛為每個用戶控件編寫的 Usrcntrl_Leave 事件的答案

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

這解決了我的問題:)

private void timer1(object sender, EventArgs e)
{
    count++;
    if (count == 2)
    {
       toolTMensaje.SetToolTip(textBox1,"");
       toolTMensaje.Hide(textBox1);
       count = 0;
       timer1.Stop();
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM