【问题标题】:how to apply different tooltip for every item in a checkbox list in winforms?如何为winforms中复选框列表中的每个项目应用不同的工具提示?
【发布时间】:2014-12-19 03:11:44
【问题描述】:

我尝试为复选框列表中的项目添加工具提示,它适用于整个复选框,但我需要为 winform 中的复选框列表中的每个项目应用不同的工具提示。我是初学者。有人可以帮忙吗? 提前致谢!

【问题讨论】:

    标签: winforms for-loop tooltip checkboxlist


    【解决方案1】:

    我会使用有关每个条目的额外信息来更新标签(在我看来,动态更改工具提示很麻烦)。您可以使用 MouseMove() 事件并检查光标是否在 GetItemRectangle() 返回的矩形范围内:

    Private Sub CheckedListBox1_MouseMove(sender As Object, e As MouseEventArgs) Handles CheckedListBox1.MouseMove
        Dim pt As Point = CheckedListBox1.PointToClient(Cursor.Position)
        For i As Integer = 0 To CheckedListBox1.Items.Count - 1
            If CheckedListBox1.GetItemRectangle(i).Contains(pt) Then
                Label1.Text = "Info about: " & CheckedListBox1.Items(i).ToString
                Exit For
            End If
        Next
    End Sub
    

    【讨论】:

      猜你喜欢
      • 2011-12-28
      • 2010-09-16
      • 1970-01-01
      • 2019-06-08
      • 1970-01-01
      • 2016-08-25
      • 2021-01-29
      • 1970-01-01
      相关资源
      最近更新 更多