Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid. Assign a different ToolTipText for each row

Status
Not open for further replies.

ejanakieff

Programmer
Sep 9, 2003
62
0
0
ES
Is it possible assign a different "ToolTipText" value for each row of a DataGrid?

I want that the "ToolTipText" shows the full value of the row when the mouse is moved over the row.

Thanks,
EVA
 
You could do this with an array of tooltips.
If you have some sort of id number in the grid starting from 0 or 1, you could add the full info into the corresponding array-element. When the pointer moves over the grid, get the id, copy the array-element into the tooltip property and the full info is shown as tooltip.
There might be other (better) sollutions, but this one came to me first, so...

Merlin is the name, and logic is my game...
 
I would like show in the ToolTipText the full content of the row when the end user move the mouse over it, because the DataGrid has a feixed width, and the content of some rows not are full visualized.
 
Use the MouseMove event and set the ToolTipText property to the column text for the column and row that the mouse is over.
 
I do something like this:

I obtain the row that the mouse is over, dividing the position "Y" (the event MouseMove give me this position) by the height of the rows. Everything works well until the user uses vertical scrollbar.

There is some other way to obtain the column and row that the mouse is over?

Thanks, EVA


 
DataGrid1.ColContaining(x)
DataGrid1.RowContaining(y)
 
Ok, it works only If i don't use the vertical scroll bar.
Because if I do a down vertical scroll, and move the mouse over the first visible row it returns "0", and the row is "21", because are 20 rows visibles at same time.

If I knows if the vertical scroll was down or up, I can sum or rest 20 rows.

Do you know how can I get this?

 
Then you need to only have this code run if the
DataGrid1.ColContaining(x) >=0 Or DataGrid1.ColContaining(x) < DataGrid1.Columns.Count

!!!!
 
I know that this is for not run the code if the mouse isn't over a row, but my problem is determine the row over the mouse is, if a scroll has done before.

For example, how to determine the row number if the mouse is over the 25 row, and the datagrid only shows 20 rows at a time.
 
Here is the code I used in the MSFlexGrid control

Private Sub grdParts_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)

Dim lngCount As Long
Dim lngRow As Long

For lngCount = 1 To grdParts.Rows
If grdParts.RowIsVisible(lngCount) = True Then Exit For
Next

lngRow = lngCount + CInt((y / grdParts.RowHeight(0)) - 0.5) - 1

grdParts.ToolTipText = grdParts.TextMatrix(lngRow, 1) & &quot; &quot; & grdParts.TextMatrix(lngRow, 2) & &quot; &quot; & grdParts.TextMatrix(lngRow, 3)

'Debug.Print x & &quot; &quot; & lngCount + CInt((y / grdParts.RowHeight(0)) - 0.5)

End Sub

Here is the code for the DataGrid

Private Sub DataGrid1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Dim RowValue As Long
Dim intCols As Integer
Dim strToolTip As String

RowValue = DataGrid1.RowContaining(Y)

If RowValue <> -1 Then

For intCols = 0 To DataGrid1.Columns.Count - 1
strToolTip = strToolTip & &quot; &quot; & DataGrid1.Columns(intCols).CellValue(DataGrid1.RowBookmark(RowValue))
Next

End If
DataGrid1.ToolTipText = strToolTip


End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top