我想在vb.net winforms中的绑定数据网格中的每一行添加一个工具提示。如何做到这一点?
我自己还没有尝试过,但我会尝试一下:
System.Windows.Forms.ToolTip formToolTip = new System.Windows.Forms.ToolTip();
formToolTip .SetToolTip(item, "Row Tooltip");
其中item
对应于要为其设置工具提示的单元格。
row.cells[indexof].ToolTipText= "tootip here".
在winforms中,看起来你不能完成整行。
如果你需要整行,你可以在单元格中循环。
foreach (DataGridViewCell cell in row.Cells)
{
cell.ToolTipText = "tooltip here";
}
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