'Powershell : How to Add Clickable Text in a WPF RitchTextBox?
I have a problem in using the RichTextBox for a WPF in Powershell.
I'm loading a file.txt that have is own meta inside and i get this meta to underline / bold .... the classic text formatting.
One of this meta is Link so i want to make the values clickable in my Richtextbox
@{" Amiforce-Distribution (important!) " link "amiforce"}
The Links autodetection in RichTextBox only working double \ and "http" like texts.
Question : Is there a way please to "AppendText" that is clickable and which is captured by the event handler $RichTextBox_LinkClicked = [System.Windows.Forms.LinkClickedEventHandler]{} ?
I checked all the urls i found on google about this subject but all are for C# and i found nothing usefull for my Powershell :)
La meilleur piste que j'ai trouvé consiste à créer un objet linklabel et d'essayer de l'appendtext dans ma richtextbox mais cela ne marche pas :
$Textlink = New-Object System.Windows.Forms.LinkLabel
$Textlink.text = "AMIGA"
$Richtextbox.AppendText("$Textlink `n")
Mais cela ne marche pas chez moi.
Pour mémoire voici les propriétées de l'objet LinkLabel
https://docs.microsoft.com/fr-fr/dotnet/api/system.windows.forms.linklabel?view=windowsdesktop-6.0
Help Please Help :)
Solution 1:[1]
I found a way to do it after more research, i hope it will help peoples
$Textlink = New-Object System.Windows.Forms.LinkLabel
$Textlink.text = "AMIGA"
$Textlink.Name = "AMIGALINK"
$Textlink.Location = $MainTextBoxOutput.GetPositionFromCharIndex($MainTextBoxOutput.TextLength)
$richtextbox.AppendText("$Textlink.text `n")
$richtextbox.Controls.Add($Textlink)
$richtextbox.SelectionStart = $richtextbox.TextLength
Best regards,
AMIGA Rulez
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Amiga1200 |
