Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a Richtextbox in my windows form application when i am getting value from this in crystal report text object its showing like this:

C#
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Calibri;}{\f1\fnil\fcharset0 Microsoft Sans Serif;}}
{\colortbl ;\red49\green132\blue155;}
\viewkind4\uc1\trowd\trgaph108\trleft-108\trbrdrt\brdrs\brdrw20 \trbrdrb\brdrs\brdrw20 \clbrdrt\brdrw15\brdrs\clbrdrb\brdrw15\brdrs \cellx3084\clbrdrt\brdrw15\brdrs\clbrdrb\brdrw15\brdrs \cellx6276\clbrdrt\brdrw15\brdrs\clbrdrb\brdrw15\brdrs \cellx9468\pard\intbl\sl276\slmult1\cf1\b\f0\fs48 Name\cell F Name\cell Last\cell\cf0\b0\row
\trowd\trgaph108\trleft-108\trbrdrt\brdrs\brdrw20 \trbrdrb\brdrs\brdrw20 \clbrdrb\brdrw15\brdrs \cellx3084\clbrdrb\brdrw15\brdrs \cellx6276\clbrdrb\brdrw15\brdrs \cellx9468\pard\intbl\sl276\slmult1\cf1\b\cell\b0\cell\cell\cf0\row
\pard\f1\fs17\par
}


My code of getting value:
C#
TextObject  report = (TextObject)cryRpt.ReportDefinition.Sections["Section3"].ReportObjects["Text7"];
 report.Text = rt.Rtf;
Posted
Updated 13-Jan-16 23:42pm
v2
Comments
Leo Chapiro 14-Jan-16 3:54am    
And what is exactly the problem with your code? Any error message, exception ?
Muhammad Qasim Ludin 14-Jan-16 3:57am    
no my resault of code on page is

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Calibri;}{\f1\fnil\fcharset0 Microsoft Sans Serif;}}
{\colortbl ;\red49\green132\blue155;}
\viewkind4\uc1\trowd\trgaph108\trleft-108\trbrdrt\brdrs\brdrw20 \trbrdrb\brdrs\brdrw20 \clbrdrt\brdrw15\brdrs\clbrdrb\brdrw15\brdrs \cellx3084\clbrdrt\brdrw15\brdrs\clbrdrb\brdrw15\brdrs \cellx6276\clbrdrt\brdrw15\brdrs\clbrdrb\brdrw15\brdrs \cellx9468\pard\intbl\sl276\slmult1\cf1\b\f0\fs48 Name\cell F Name\cell Last\cell\cf0\b0\row
\trowd\trgaph108\trleft-108\trbrdrt\brdrs\brdrw20 \trbrdrb\brdrs\brdrw20 \clbrdrb\brdrw15\brdrs \cellx3084\clbrdrb\brdrw15\brdrs \cellx6276\clbrdrb\brdrw15\brdrs \cellx9468\pard\intbl\sl276\slmult1\cf1\b\cell\b0\cell\cell\cf0\row
\pard\f1\fs17\par
}
DamithSL 14-Jan-16 5:37am    
Right click on the field, then select Format Field -> Paragraph tab -> Text Interpretation -> RTF text.
Muhammad Qasim Ludin 14-Jan-16 7:26am    
its not FieldObject its TextObject in textobject there is no option of Text interpretation
BillWoodruff 14-Jan-16 11:05am    
You need to use the object in Crystal Reports that supports the RTF format. See:

http://stackoverflow.com/questions/186699/displaying-richtext-in-crystal-reports

1 solution

You ask

C#
report.Text = rt.Rtf;


Quote:
Gets or sets the text of the RichTextBox control, including all rich text format (RTF) codes.


You need to use
C#
report.Text = rt.Text;


Quote:
Gets or sets the current text in the rich text box.(Overrides TextBoxBase.Text.)
Quote:
 
Share this answer
 
v2
Comments
Muhammad Qasim Ludin 14-Jan-16 7:24am    
i used this method but its losing format just contents is coming in report textbox
Leo Chapiro 14-Jan-16 7:55am    
I thought that is what you need? If not, can you please explain, what is your goal?
Muhammad Qasim Ludin 14-Jan-16 8:05am    
i want to print some contents which is retrieving from database correctly with correct format but when i am delivering to crystal report in text object of crystal report its not showing correctly to print

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900