|
-
May 22nd, 2009, 07:44 AM
#1
Clipboard and C# How does this work ?
Hi friends !
I have created a code by use of an example which works, ...
But I dont know WHY
the code is
Code:
void wordLoader_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
IDataObject data = Clipboard.GetDataObject();
_rtbDoc.Paste(); // RTB is my Richtextbox
....
In the worker thead I'm opening a word document selecting it by use of 'WholeStory' and copying the selection. So This I understand loads it into the clipboard. But in the above code the red italic line what does it do ? Because IDataobject is not used anywhere else in all of my code. But if I delete this line the paste method of my richtextbox stays empty.
Also I tried to use it just after reading the data in the 'do delegate' of the backgroundworker and having the paste() method in the Completed method. This also results in an empty RTB. So what does the method Clipboard.GetDataobject do with the data so Paste() can read from the clipboard.
I'm asking because I hate things which I cannot understand, they seem to tend to be risky , because maybe then sometimes it will work, sometimes fail, I dont know. Who can explain me what goes on behind the scenes.
 Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
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
|