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.RichTextB ox MyRTF = new
System.Windows. Forms.RichTextB ox();
MyRTF.LoadFile( "e:\\projects\\ iso\\hmm\\h.rtf ");
MyRTF.SelectAll ();
MyRTF.Copy();
System.Windows. Forms.IDataObje ct data =
System.Windows. Forms.Clipboard .GetDataObject( );
if (data.GetDataPr esent(System.Wi ndows.Forms.Dat aFormats.Rtf))
{
ftb.Text = data.GetData(Sy stem.Windows.Fo rms.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.NullRefe renceException: Object reference not set
to an instance of an object.
Source Error:
Line 67: ftb.ToolbarLayo ut = "Paste";
Line 68: System.Windows. Forms.IDataObje ct data =
System.Windows. Forms.Clipboard .GetDataObject( );
Line 69: if (data.GetDataPr esent(System.Wi ndows.Forms.Dat aFormats.Rtf))
Line 70: {
Line 71: ftb.Text =
data.GetData(Sy stem.Windows.Fo rms.DataFormats .Rtf).ToString( );
=============== ===============
Thanks for help.