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.
This topic is 2 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Tooltip on Cell in DGV

Post by apowershelluser »

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 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
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Tooltip on Cell in DGV

Post by apowershelluser »

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 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
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Tooltip on Cell in DGV

Post by apowershelluser »

Thank you, I don't have this implemented quite yet but you gave me the blocks and really appreciate the two other files.
This topic is 2 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked