【问题标题】:How can tooltips be added to a vb.net winforms datagrid row(s)?如何将工具提示添加到 vb.net winforms 数据网格行?
【发布时间】:2008-10-20 19:31:40
【问题描述】:

我希望在 vb.net winforms 的绑定数据网格中的每一行中添加一个工具提示。如何做到这一点?

【问题讨论】:

    标签: vb.net winforms data-binding .net-2.0 tooltip


    【解决方案1】:

    我自己没有尝试过,但我会试一试:

    System.Windows.Forms.ToolTip formToolTip = new System.Windows.Forms.ToolTip();
    formToolTip .SetToolTip(item, "Row Tooltip");
    

    item 对应于您为其设置工具提示的单元格。

    【讨论】:

      【解决方案2】:
      row.cells[indexof].ToolTipText= "tootip here".
      

      在 winforms 中,您似乎无法完成整行。

      如果您需要整行,您可以遍历单元格。

       foreach (DataGridViewCell cell in row.Cells)
                      {
                          cell.ToolTipText = "tooltip here";
                      }
      

      【讨论】:

        【解决方案3】:
        If TypeOf control Is TabControl Then
            For Each control1 In control.Controls
                If TypeOf control1 Is TabPage Then
                    strControlText = fnGetLanguage(control1.Text)
                End If
                For Each control2 In control1.Controls
                    If TypeOf control2 Is label Then
                        strControlText = control2.Text
                        ' strToolTipText = ToolTip.GetToolTip(control2)
                        If strControlText.Contains("*") Then
                            strDizi = Split(strControlText, " ")
                            strControlText = fnGetLanguage(strDizi(0))
                        Else
                            strControlText = fnGetLanguage(control2.Text)
                        End If
                    ElseIf TypeOf control2 Is DataGridView Then
                        For i = 0 To control2.ColumnCount - 1
                            strControlText = control2.Columns(i).HeaderText
                            strControlText = fnGetLanguage(strControlText)
                        Next
                    ElseIf TypeOf control2 Is ComboBox Then
                        strControlText = control2.Text
                        'strToolTipText = ToolTip.GetToolTip(control2)
                        If control2.DataSource Is Nothing Then
                            For i = 0 To control2.Items.Count - 1
                                strControlText = control2.Items(i)
                                strControlText = fnGetLanguage(strControlText)
                            Next
                        Else
                            For i = 0 To control2.Items.Count - 1
                                strControlText = control2.Items(i).ToString
                                strControlText = fnGetLanguage(strControlText)
                            Next
                        End If
                    End If
                Next
            Next
        End If
        

        【讨论】:

          猜你喜欢
          • 2013-06-02
          • 2014-02-12
          • 2017-01-16
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-05-10
          • 1970-01-01
          相关资源
          最近更新 更多