RichTextBox: Adding dynamically-generated picture to existing content

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 5 years and 1 week 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
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: RichTextBox: Adding dynamically-generated picture to existing content

Post by jvierra »

We can also place an object on the clipboard that does not remain.

https://docs.microsoft.com/en-us/dotnet ... work-4.7.2
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: RichTextBox: Adding dynamically-generated picture to existing content

Post by jvierra »

With the Net Framwork we can also use this to copy and restore the clipboard


# save clipboard contents
$clp = [System.Windows.Forms.Clipboard]::GetDataObject()
# restore clipboard contents
[System.Windows.Forms.Clipboard]::SetDataObject($clp)
User avatar
zmilbourn
Posts: 8
Last visit: Tue Dec 14, 2021 10:48 am

Re: RichTextBox: Adding dynamically-generated picture to existing content

Post by zmilbourn »

Thanks for going the extra mile to help me with this. I have removed any code I had previously utilized/posted, and have swapped it out to your correct/efficient code.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: RichTextBox: Adding dynamically-generated picture to existing content

Post by jvierra »

I just wanted you to understand why your code was unusable and unnecessary so you would understand how PowerShell, Net and the clipboard work.
This topic is 5 years and 1 week 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