|
-
Aug 20th, 2019, 11:16 AM
#5
Re: Richtextbox RTF - I learned something
I would assume that
rtb.Rtf = rtbIn.Rtf
isn't making a copy of the text, it is copy of a reference, so both rtbs are referencing the same Gui object.
Later when you try to use that reference from the other thread, you get the error because you're trying to reference an object created on the Gui thread.
The .Text might work, because .Text is a String, and a String is treated as a Value type, not a reference type. So, both rtb's may be referencing the same string, but because it is treated as a value type, and is immutable, it won't cause a object Cross-thread operation error.
In either case, since it seems like you intend to make a copy of the data, rather than a reference to the data, you shouldn't be doing an assignment like you are. I don't know if the .Rtf has a clone method to create a copy or not. Should look it up, but not curious enough.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|