.rtf->clipboard->FreeTextBox

From: Markusek Peter (markyp.AT.centrum.sk)
Date: 02/22/04


Date: Sun, 22 Feb 2004 21:47:33 +0100

Hi.
I want to get rtf to my FreeTextBox(ftb instance in code below). So I copy
.rtf to clipboard, and now I want to paste it from clipboard to ftb. But I
got error 'Object reference not set to an instance of an object.'
Here's my code:

--
System.Windows.Forms.RichTextBox MyRTF = new
System.Windows.Forms.RichTextBox();
MyRTF.LoadFile("e:\\projects\\iso\\hmm\\h.rtf");
MyRTF.SelectAll();
MyRTF.Copy();
System.Windows.Forms.IDataObject data =
System.Windows.Forms.Clipboard.GetDataObject();
if (data.GetDataPresent(System.Windows.Forms.DataFormats.Rtf))
{
ftb.Text = data.GetData(System.Windows.Forms.DataFormats.Rtf).ToString();
}
--------------
Here is error:
--
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
Line 67: 			ftb.ToolbarLayout = "Paste";
Line 68: 			System.Windows.Forms.IDataObject data =
System.Windows.Forms.Clipboard.GetDataObject();
Line 69: 			if (data.GetDataPresent(System.Windows.Forms.DataFormats.Rtf))
Line 70: 			{
Line 71: 				ftb.Text =
data.GetData(System.Windows.Forms.DataFormats.Rtf).ToString();
==============================
Thanks for help.


Relevant Pages

  • Re: .rtf->clipboard->FreeTextBox
    ... but I understand what he is trying to accomplish and replied to ... >> I want to get rtf to my FreeTextBox. ... >> I copy .rtf to clipboard, and now I want to paste it from clipboard ... >> Object reference not set to an instance of an object. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: .rtf->clipboard->FreeTextBox
    ... Every reference in it is to ... > .rtf to clipboard, and now I want to paste it from clipboard to ftb. ... > Object reference not set to an instance of an object. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Clipboard Related Question
    ... however the option of inserting a file is not the best because ... >>paste it into a word doc with the important formatting!, ... >>formatting (I can get it to the clipboard by reading from the database ... probably also of the RTF content you have. ...
    (microsoft.public.dotnet.general)
  • Re: RTF in Access: Lebans RTF2 export issue
    ... hardcoding how this report would look like, which only a programmer with RTF ... > contents copied to the Clipboard. ... > If you need to programmatically insert your RTF data into a MS Word ...
    (microsoft.public.access.reports)
  • Re: Clipboard Data conversion...!
    ... >> Thanks Mike, ... >> If i copy on ClipBoard RTF and Get back RTF all OK, ... > require a reasonable knowledge of both the RTF and HTML file formats. ...
    (microsoft.public.vb.winapi)