Product, version and build:
64 bit version of product: 5.5.155
Operating system: Win10x64
*** Please add details and screenshots as needed below. ***
I published a GUI that had a RichTextBox control with DetectUrls = True with a link inside of it like in the example below:
"If you would like more information, click this link: <https://example.com/info.html>"
It worked great. But now, I needed to add a couple of additional links as in the example below:
"If you would like more information, click this link: <https://example.com/info.html>
If read the policy, click here: <https://example.com/sure.html>
For further questions, click here: <https://example.com/notsure.html>"
It compiles fine and looks good.. but none of the links work. Am I doing something wrong or is each RichTextBox limited to finding one link?
Thanks,
Kerbob
Richtextbox with multiple URLs
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.
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.
Re: Richtextbox with multiple URLs
[TOPIC MOVED TO POWERSHELL GUIS FORUM BY MODERATOR]
I ran a quick test and the RichTextBox is returning the correct links in the LinkClicked event:
You must to handle the LinkClicked event in order to display the website.
I ran a quick test and the RichTextBox is returning the correct links in the LinkClicked event:
- $richtextbox1_LinkClicked=[System.Windows.Forms.LinkClickedEventHandler]{
- #Event Argument: $_ = [System.Windows.Forms.LinkClickedEventArgs]
- #TODO: Place custom script here
- Write-Host $_.LinkText
- }
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: Richtextbox with multiple URLs
This is a good one!
Just keep in mind, when working with Windows Form controls, you're dealing with events. So, you need to add the event for the when you click the Url link.
This is the "LinkClicked" event.
This is well documented in the Microsoft Doc: https://docs.microsoft.com/es-es/dotnet/api/system.windows.forms.richtextbox.detecturls?redirectedfrom=MSDN&view=netframework-4.7.2
Now, to add the event to the form, just Right-Clicked on the RichTextBox control, then select "Add Events".
Select (Checked) the "LinkClicked" event, and this will be added to the script section of the control.
For example:
After the event code block has been added, the include the following code:
Now, you can run the form with the RichTextBox showing any Urls that can the executed running the browser.
Hope this helps!
Just keep in mind, when working with Windows Form controls, you're dealing with events. So, you need to add the event for the when you click the Url link.
This is the "LinkClicked" event.
This is well documented in the Microsoft Doc: https://docs.microsoft.com/es-es/dotnet/api/system.windows.forms.richtextbox.detecturls?redirectedfrom=MSDN&view=netframework-4.7.2
Now, to add the event to the form, just Right-Clicked on the RichTextBox control, then select "Add Events".
Select (Checked) the "LinkClicked" event, and this will be added to the script section of the control.
For example:
Code: Select all
$richtextbox1_LinkClicked=[System.Windows.Forms.LinkClickedEventHandler]{
#Event Argument: $_ = [System.Windows.Forms.LinkClickedEventArgs]
#TODO: Place custom script here
}
Code: Select all
#.NET CSharp code => System.Diagnostics.Process.Start(e.LinkText);
[System.Diagnostics.Process]::Start($_.LinkText)
Hope this helps!
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: Richtextbox with multiple URLs
Mr Jvierra!
Oops! I thought when I did the translate to english that the Url will keep it in "English".
I wasn't expecting to stay in spanish language.
Haha!
Also, I was showing the code translation from C#.
Thanks for showing the "Start-Process" cmdlet.
Oops! I thought when I did the translate to english that the Url will keep it in "English".
I wasn't expecting to stay in spanish language.
Haha!
Also, I was showing the code translation from C#.
Thanks for showing the "Start-Process" cmdlet.
Re: Richtextbox with multiple URLs
Max,
Use either. I just posted the alternate as another choice. It may be easier to remember.
Also just change the url "es-es" to "en-US" and it will be in English again.
Use either. I just posted the alternate as another choice. It may be easier to remember.
Also just change the url "es-es" to "en-US" and it will be in English again.