Change curser over RichTextBox line when that text is bold

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
zsirkin
Posts: 11
Last visit: Tue May 02, 2023 2:21 pm

Change curser over RichTextBox line when that text is bold

Post by zsirkin »

I would like for the curser to change from the default iBeam to a hand once it's entering the line that is bolded.
Ideally I would like to see it function like hypertext.
I've added a snippet of what it currently looks like at the bottom.


Bonus: Also, it would be create if someone can tell me how to keep text from getting highlighted when I click the clickable Bold item :)

This is the code for clicking a portion of the RTB

$firstChar = $richtextbox1.GetFirstCharIndexOfCurrentLine()
$currentLine = $richtextbox1.GetLineFromCharIndex($firstChar)
$currentLineText = $richtextbox1.Lines[$currentLine]


if ($currentLineText -like "Username: *")
{
$richtextbox1.Select($firstChar, $richtextbox1.TextLength)

$buttonSetUser.PerformClick()
$ticket.Text = "Ticket #"
}
Attachments
rtb_snip.PNG
rtb_snip.PNG (6.64 KiB) Viewed 2012 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Change curser over RichTextBox line when that text is bold

Post by jvierra »

You have to track the mouse and read what is under the mouse cursor. That will be very complex piece of programming. Your request seems to indicate that you likely should not be doing this with an RTF control.
Second question seems to be of the same order of misuse of control. It is critical to design to the controls and their intended method of use. WHile it is often possible to stretch a controls use it is more often a bad idea in code and in design.
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