ToolTips for cells in a grid?

  • Thread starter Thread starter Woody Splawn
  • Start date Start date
W

Woody Splawn

Is it possible to get a tooltip for a cell in a datagrid? If so How? Is
there a white paper somewhere?
 
Hi Woody,

Here the standard sample I made to add a textbox to a column in that I use
in my opinion what you ask.

\\\
Private WithEvents dtbCol1 As DataGridTextBox
Private ToolTip1 As New ToolTip
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Datagrid1.ReadOnly = True
Dim ts As New DataGridTableStyle
ts.MappingName = ds.Tables(0).TableName
Dim column As New DataGridTextBoxColumn
ts.GridColumnStyles.Add(column)
DataGrid1.TableStyles.Add(ts)
column = DirectCast(ts.GridColumnStyles(0), DataGridTextBoxColumn)
dtbCol1 = DirectCast(column.TextBox, DataGridTextBox)
column.MappingName = ds.Tables(0).Columns(0).ColumnName
column.HeaderText = "Woody"
column.Width = 30
dv = New DataView(ds.Tables(0))
dv.AllowNew = False
DataGrid1.DataSource = dv
End Sub
Private Sub dtbCol1_ToolTip(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles dtbCol1.MouseEnter
ToolTip1.SetToolTip(DirectCast(sender, DataGridTextBox), _
"Row: " & DataGrid1.CurrentRowIndex + 1)
End Sub

It was not for the tooltip so you have a little bit to make it complete,

I hope it helps?

Cor
 
Woody,

I saw the one in the previous message was not easy to test so here a one
with what that can be done, (the textbox has to be selected to see the
tooltip)

Cor

\\\needs a datagrid on a form
Private WithEvents dtbCol1 As DataGridTextBox
Private ToolTip1 As New ToolTip
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
'making test table
Dim ds As New DataSet
Dim dt As New DataTable("test")
ds.Tables.Add(dt)
dt.Columns.Add("1")
For i As Integer = 0 To 10
Dim dr As DataRow = dt.NewRow
dr(0) = i
dt.Rows.Add(dr)
Next
'table made
DataGrid1.ReadOnly = True
Dim ts As New DataGridTableStyle
ts.MappingName = ds.Tables(0).TableName
Dim column As New DataGridTextBoxColumn
ts.GridColumnStyles.Add(column)
DataGrid1.TableStyles.Add(ts)
column = DirectCast(ts.GridColumnStyles(0), DataGridTextBoxColumn)
dtbCol1 = DirectCast(column.TextBox, DataGridTextBox)
column.MappingName = ds.Tables(0).Columns(0).ColumnName
column.HeaderText = "Woody"
column.Width = 30
Dim dv As New DataView(ds.Tables(0))
dv.AllowNew = False
DataGrid1.DataSource = dv
End Sub
///
I hope this helps a little bit?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top