2016-04-06 11 views
-1

多くの開発者が、彼のためにリアルタイムのツールチップを書くことができます。あなたは私の質問を理解していない場合
ので、ここで私はスムーズに私のカーソルを次のようにツールチップをしたいの例VB.NETでリアルタイムのツールチップを使用

Not real time
で、誰もが私のコードを伝えることができますか?

+0

のようにタイマーや何かを使用し、あなたが何を意味するのか?、特定 – Danny

+0

ようにしてください[この](のhttp:// www.dotnetperls.com/tooltip)? –

+0

自動的に表示するためにシステムに頼るのではなく、コードで 'ToolTip'を表示するだけです。 – jmcilhinney

答えて

1

これはあなたが求めたことを行います。私が言ったように、あなたは単にToolTipを表示して、あなたのためにそれを行うためにシステムに頼らないでください。

Private Sub Button1_MouseMove(sender As Object, e As MouseEventArgs) Handles Button1.MouseMove 
    Dim text = e.Location.ToString() 

    If text <> Me.ToolTip1.GetToolTip(Me.Button1) Then 
     Me.ToolTip1.Show(e.Location.ToString(), Me.Button1, New Point(e.X + 20, e.Y + 20)) 
    End If 
End Sub 

Private Sub Button1_MouseLeave(sender As Object, e As EventArgs) Handles Button1.MouseLeave 
    Me.ToolTip1.Hide(Me.Button1) 
End Sub 
+0

ええと、あなたのコードは単純ではなく、ちょうど1行のコードが必要です:-) –

+0

関連するコードの行数は何故ですか? – jmcilhinney

+0

私のアプリでは多くの行があると思うので、私のアプリは読み込みが遅くなります –

0

あなたがツールチップは、マウスをフォローしたい場合は、多分this

Public Class Form1 

Private toolTipMsg As String = "Busy, Please Wait..." & vbCrLf & "Line2 Blah bla bla." 

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load 
    ToolTip1.Active = True 
    ToolTip1.IsBalloon = False 
    Timer1.Start() 
End Sub 

Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick 
    ' get cursor position 
    Dim cp = Cursor.Position 
    ' offset Y so tooltip is under mouse 
    cp.Y += CInt(Cursor.Size.Height * 1.5) 
    ' show tooltip 
    ToolTip1.Show(toolTipMsg, Me, PointToClient(cp)) 
End Sub 
+0

あなたのコードには、「Busy、Please Wait ... Line2 Blah bla bla。」というテキストが表示されたツールチップが常に表示されます。 –

+0

メッセージを「toolTipMsg = ..」に変更することができます –

+0

私はそのコードを知っています –

関連する問題