Tooltip on Cell in DGV

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
JohnTitor
Posts: 166
Last visit: Fri Aug 13, 2021 3:06 pm

Tooltip on Cell in DGV

Post by JohnTitor »

I was looking to display a tooltip when I enter a cell and found this post:

viewtopic.php?f=21&t=15000&p=78696&hili ... tip#p78696

It appears there are C examples, but its a bit more complex for me however appears to be doable.

For example, I have a CSV with PCs,ModelTypes and PC Numbers

My DGV only shows( on purpose ):
Model Type | Count

I would like when I enter the cell containing the count to display the PCNumbers in a tooltip

jvierra
Posts: 14951
Last visit: Sun Oct 17, 2021 11:52 am
Answers: 14
Has voted: 3 times
Been upvoted: 11 times

Re: Tooltip on Cell in DGV

Post by jvierra »

The best we can say is to look up the pc numbers when the toltip is clicked and set the text to the numbers you have loked up.

jvierra
Posts: 14951
Last visit: Sun Oct 17, 2021 11:52 am
Answers: 14
Has voted: 3 times
Been upvoted: 11 times

Re: Tooltip on Cell in DGV

Post by jvierra »

Here is one of a number of ways to do this. This method alows you to set the list on a cell.

https://docs.microsoft.com/en-us/dotnet ... ew=net-5.0

User avatar
JohnTitor
Posts: 166
Last visit: Fri Aug 13, 2021 3:06 pm

Re: Tooltip on Cell in DGV

Post by JohnTitor »

This statement is incorrect
For example, I have a CSV with PCs,ModelTypes and PC Numbers

It’s ModelTypes, Total counts, PCs of each type

Sorry

Thanks for the example, that’s the article that’s over my head :?

I know it’s a rare ask, I have another ask specific to you

Do you still have these files from this post?

http://tech-comments.blogspot.com/2017/ ... m.html?m=1

Appears they no longer exist on onedrive

jvierra
Posts: 14951
Last visit: Sun Oct 17, 2021 11:52 am
Answers: 14
Has voted: 3 times
Been upvoted: 11 times

Re: Tooltip on Cell in DGV

Post by jvierra »

I don't understand, what is incorrect? Just add the field to the TooTipText of teh cell and it will display as a tooltip when hovered.

Simple example:

  1. $rowdata = @('ONE','TWO','THREE')
  2. $pclist = 'pc100,pc200,pc300'
  3.  
  4. $form1_Load={
  5.     $idx = $datagridview1.Rows.Add()
  6.     $row = $datagridview1.Rows[$idx]
  7.     $row.SetValues($rowdata)
  8.     $row.Cells[0].ToolTipText = $pclist -replace ',',"`n"
  9. }
  10.  
Here are the reconstituted sharreable links.

https://1drv.ms/u/s!AjiiPtIUqzK_hbMBVsK_ER1NyyCk7A

https://1drv.ms/u/s!AjiiPtIUqzK_hbMEzLcQXXeSDeKm1g

User avatar
JohnTitor
Posts: 166
Last visit: Fri Aug 13, 2021 3:06 pm

Re: Tooltip on Cell in DGV

Post by JohnTitor »

Thank you, I don't have this implemented quite yet but you gave me the blocks and really appreciate the two other files.

Locked