C# Clipboard - need data persistence after application is closed

I am writing a simple c# (VS2005) application to put data on a clipboard from a listbox. It is all working correctly - I can paste the data from the clipboard into wordpad, etc.  
The problem comes when I close my C# application.  The data disappears from the clipboard.  I would like it to be persistent.  I assumed since it was on the system clipboard, it would be available until something else was put on the clipboard.   But - it is no longer there.
Is there any way to keep it?
ampflpAsked:
Who is Participating?
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Hmm...see: http://msdn.microsoft.com/en-us/library/cs5ebdfz.aspx

    "If the copy parameter is false, the data will be deleted from system Clipboard when the application exits."

So try this instead:

    Clipboard.SetDataObject(outString, true);
0
 
systanCommented:
there are many links that can help you with that, one example is;
http://www.radsoftware.com.au/articles/clipboardmonitor.aspx
But
at least paste your code snippet?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Agreed...post your code as data I place on the clipboard is still there when my app closes.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
ampflpAuthor Commented:
Here's the code -
		private void btnCopyAll_Click(object sender, System.EventArgs e)
		{
			StringBuilder sb = new StringBuilder();
			foreach (String str1 in msgList)
			{
				sb.Append(str1);
				sb.Append("\r\n");
			}
			
			String outString = sb.ToString();
			
			Clipboard.SetDataObject(outString);
		}

Open in new window

0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
That should work...do you have any third-party clipboard managers installed or anything like that on your system?
0
 
systanCommented:
use;
Clipboard.SetText
http://msdn.microsoft.com/en-us/library/tbfb3z56.aspx

why convert to string while there is a direct way of using a clipboard string

OR

find;
Clipboard.Clear
It's impossible that the clipboard is gone without clearing it.

OR

issue a;
Clipboard.Clear, to clear the clipboard first before another one
0
 
ampflpAuthor Commented:
oh - Office Clipboard is in the taskbar icon list - could that be interfering somehow?   (I am new to this work computer, don't know if there's something else hiding out)
0
 
systanCommented:
good catch
0
 
ampflpAuthor Commented:
I missed that one - thank you so much. -
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.