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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ToolTipText on Datagrid cell question

Status
Not open for further replies.

jpack23

Programmer
Dec 15, 2004
82
US
Private Sub dgvGrid_CellMouseEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvGrid.CellMouseEnter

Dim strNote as String

strNote = GetNote()

Me.dgvGrid.CurrentCell.Tooltiptext = strNote

End Sub

This code give me an "Object reference not set to an instance of an object." error

What do I need to do to set that ToolTipText to a string variable? How do I display variable data in the pop up tooltips of a datagrid cell?

When I set the tooltiptext to "hello" (me.dgvGrid.CurrentCell.ToolTipText = "Hello")

it works fine.

Thanks for your help
 
Which line is throwing the object reference error?


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
jebenson
the line that throws the error is

Me.dgvGrid.CurrentCell.Tooltiptext = strNote


strNote I earlier set equal to the results of a call to a database....so strNote will be different for each cell. I need the tooltip to display the contents of a particular field in a database table

thanks for your help
 
Ok i figured out how to solve the problem

replaced

Me.dgvGrid.CurrentCell.ToolTipText = strNote

with

Me.dgvGrid.Rows.Item(Row).Cells.Item(Col).ToolTipText = strNote

Dont know that the difference is between currentcell and actually pointing out the row and column of the cell but I guess there is

thanks to all who tried to help
 
I don't know how to put it other than some time things don't instance right. I had a similar problem with something else (can't remember). Generally when that happens you have to assign that instance something like:

Code:
Dim cCell As DataGridViewCell = Me.dgvGrid.CurrentCell
cCell.ToolTipText = strNote

I don't do much with data grids though so I'm not sure. Which was why I never mentioned it.

-I hate Microsoft!
-Forever and always forward.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top