clickable entries in RichTextBox

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 10 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
boyddt_co
Posts: 89
Last visit: Mon Sep 25, 2023 9:36 pm

clickable entries in RichTextBox

Post by boyddt_co »

I am creating a site/server checking application and the end users decided that if a site/server fails they want to be able to click on it and get a tracert outputted. What are my options to have a link embedded in the RTB field? I've included a screenshot. So, in this example, they would want to click on Web Server and open a window that would run test-netconnection -tracert command.
SiteChecker.PNG
SiteChecker.PNG (9.68 KiB) Viewed 3539 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: clickable entries in RichTextBox

Post by jvierra »

I recommend using a ListView control as it has better support for links when displayed as a hierarchy.
User avatar
boyddt_co
Posts: 89
Last visit: Mon Sep 25, 2023 9:36 pm

Re: clickable entries in RichTextBox

Post by boyddt_co »

Thank you, I will give that a try.
User avatar
boyddt_co
Posts: 89
Last visit: Mon Sep 25, 2023 9:36 pm

Re: clickable entries in RichTextBox

Post by boyddt_co »

So I'm trying the listview box and it isn't working as expected. Using the add-listviewitem code that is automatically added, entries are duplicated. In the picture you can see the output to the GUI and the output to the console. The code where I call the add-listviewitem is included.

Sapien_ListView.PNG
Sapien_ListView.PNG (31.08 KiB) Viewed 3092 times
  1. $SitePing = $global:SiteDict[$TestCount].SitePing
  2.         $SiteName = $global:SiteDict[$TestCount].SiteName
  3.         $SiteURL = $global:SiteDict[$TestCount].SiteURL
  4.         $SitePorts = $global:SiteDict[$TestCount].Ports -split ","
  5.         $TotalPorts = $SitePorts.Count
  6.         $Path = (Split-Path $script:MyInvocation.MyCommand.Path).replace(" ", "`` ") + "\portqry.exe"
  7.         $listview1.Items.Add($SiteName + "`r`n")
  8.         Write-Host $SiteName
  9.         Add-ListViewItem -ListView $listview1 -Items $SiteName
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: clickable entries in RichTextBox

Post by jvierra »

Obviously you event is being called twice for each entry.
This topic is 2 years and 10 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