Programmatically show tooltip in winforms application

前端 未结 6 1509
[愿得一人]
[愿得一人] 2020-12-09 15:26

How can I programatically cause a control\'s tooltip to show in a Winforms app without needing the mouse to hover over the control? (P/Invoke is ok if necessary).

6条回答
  •  情话喂你
    2020-12-09 16:07

    If you create your variable private to the whole form, you will be able to call the sub for the and adjust the initialdelay.

    Public Class MyForm        
    Private MyTooltip As New ToolTip        
    ...        
    Sub ApplyToolTips        
    'For default        
    ApplyToolTips (1000)        
    End Sub        
    
    Sub ApplyTooltips (ByVal Delay as Integer)        
    
    MyTooltip .InitialDelay = Delay        
    MyTooltip.AutoPopDelay = 5000        
    ...        
    MyTooltip.SetToolTip(Me.btnClose, "Close the form")        
    
    End Sub       
    
    Private Sub Btn_Click(sender As System.Object, e As System.EventArgs) Handles Btn.Click           
        Dim PicBox As PictureBox = CType(sender, PictureBox)        
        ApplyTooltips (0)       
        ApplyTooltips (1000)       
    End Sub       
    

提交回复
热议问题