I have a multi line text box like :
<asp:TextBox CssClass="txtform" ID="txtWhom" runat="server" Height="78px"
Rows="10" TextMode="MultiLine"></asp:TextBox>
say I write the following text in that text box :
Dear Sir,
General Manager,
HSBC.
when I take that text in a variable in the vb.net code behind... and send it to a crystal report to show ... only ... the first line is shown... in that case only "Dear Sir," is shown ... but I want all the text ....
What Can I do ?
Use "Can Grow" option for that text object in Crystal report.
=>Right Click -> Text Object
=>Select Format Object
=>Use Can grow option in the dialog box.
It enables for variable length fields to grow vertically in the report and word wrap automatically. A maximum number of lines can be set with this option to control rogue or large data elements.
I wonder if your entered string includes carriage return & line feed chars that Crystal is not dealing with properly. You may need to strip those out or replace them with correct characters that Crystal expects.
Related
we are having a report generated using crystal report While generating we have a request to have a checkbox with a list of items.
The checkbox is only available in the Wingdings font.
Since we are using Arial font for the list items we can not change the font of the formula field through which we are showing the list.
Eg:
[] task1
[x] task2
we need to split each list item and replace the square brackets with checkbox form the wingdings font.
how can we create a formula for this in crystal report?
I found a way
Create a formula with this code:
stringvar MYARRAY:= Replace ({Notes1},"[]" , '< font face = "wingdings" >'&chr(254)&'< /font>');
stringVar MYARRAY1 := ' '+Replace (MYARRAY,"|" ,' < br> );
MYARRAY1;
Drag and drop this field on the report > right-click the field > Format Field > Paragraph tab > Under "Text Interpretation" select "HTML Text".
Without using HTML or RTF Text interpretation, Crystal Reports can't display two fonts in one formula field, but it is possible with a Text Object.
Create two formulas, one with the checkmark and one with the item-text.
Drag & drop the formula-fields into an empty text object.
Now you can format the two formula fields independently of each other but inside the same field.
I want to make my textbox to be able to receive multiline text from paste function and change it to single line as example below:
i want to change
this multiline text
just into single line.
please help
into
i want to change this multiline text just into single line. please help
I try to change the textmode to singleline but it end up just take the first line only. How can i do this? Below is my code. Many thanks!
<asp:Textbox id="Textbox" TextMode="MultiLine" CssClass="LongTextBox" Width="370px" Runat="server" AutoCompleteType="Disabled" autocomplete="off" AutoPostBack="true"></asp:Textbox>
You can replace the line breaks with a space.
string value = Textbox1.Text.Replace("\r\n", " ");
But if the text already contained a space before or after the line break, you'll get 2 spaces.
i want to change
this multiline text
just into single line.
please help
so you could also do this
string value = TextBox1.Text.Replace("\r\n", " ").Replace(" ", " ");
I have a textpad file that has rows of text. For e.g.
Cat: Meaning - animal. The cat ran up the house
Rat: Meaning- rodent. The rat lives in the borough and feeds on leftovers
Word 3: Description
Word 4: Description
I have many such record in my file. I want to insert a line break at the end of every record for proper presentation. Doing it manually is tedious. Please help if you know an automated process to insert line break.
You can quickly do this by using a feature called "Regular Expressions" to find and add empty lines.
Open up the Find/Replace (Search menu > Replace)
In the "Find what" field, type the following: (^.+$)\n(^.+$)
In the "Replace with" field, type the following: \1\n\n\2
Tick the "Regular expression" checkbox
Click the Replace All button at least twice, but perhaps 3 times, until you get the message Cannot find the Regular Expression
Untick the "Regular expression" checkbox
Close the Replace dialog
Confirm the file is formatted as you are expecting
Save the file.
You can write a simple C# prgram that uses a loop that adds this code after every line :
But first add the namespace using System.Enviorment
Enviorment.NewLine;
If you have any more trouble i'll help with some code to get started
Open up the Find/Replace (Search menu > Replace)
In the "Find what" field, type the following so that the replace occurs at the end of each line: $
In the "Replace with" field, type the following. Note each 'n' represents a <return>. In this instance, I added a return at the end of a SQL statement, the word 'GO' on the next line and another <return>: \n\GO\n
Started with text file containing:
select * from <tablename>
select * from <tablename>
Ended with text file containing:
select * from <tablename
GO
select * from <tablename>
GO
Hope that helps.
from your text it is difficult to understand what you are intending to do. I'll give you some questions. The answers will help others to help you.
Do you really mean textpad as the product from company helios in UK or do you use this word as a general word for a class of tools (like notepad - but there is a general definition AND the tool as part of Windows).
Your file hase line breaks yet. You don't see them, but in the file itself they are present (in Unix systems line feed (hex code 0A) or in the windows world carriage return followed by line feed (hex code 0D 0A)).
Or would you like to publish your text in HTML? So you have to put the necessary tags around each line like paragraph, line break, list item etc.?
I want to format the content before showing to web page. I am storing '\r\n\' as enter in Database and trying to replace it before show content on the web page. server side my code is:
lblComments.Text = Server.HtmlEncode(((DataRowView)e.Item.DataItem).Row["Comment"].ToString().Replace("\r\n", "<br>"));
I have use Server.HtmlEncode.
My Out put should be:
Comment Type: Public
Comment: Commented on the Data by user A
But, its shows me everything in single line.
You need to use
.Replace("\r\n", "<br/>")
And only AFTER Server.HtmlEncode, because you don't want the <br/> itself to get encoded to <br/> (raw), displaying as <br/> literally.
You could wrap the output in a <pre>...</pre> element instead of replacing the line breaks with <br>. That way, the line breaks should be conserved.
E.g. put a <pre> element around your Label:
<pre><asp:Label id="lblComments" runat="server" /></pre>
Try
Replace("\n", "<br>")
This test worked without encode
string comments = #"Comment Type: Public
Comment: Commented on the Data by user A";
lblComments.Text = comments.Replace("\n","<br>");
When I try and display text from an the InnerText from an XML element. I get something like this:
I need this spacing \r\n\r\n\r\second lot of spacing\r\n\r\nMore spacing\r\n\r\n
I know you can replace \r\n with <br> but is there no function that automatically takes the html for you and why does it use \r and \n? Many thanks.
You can use <pre> tag - it will show the text as-is like you see it in text editor:
For example:
<pre><%=MyText%></pre>
Better practice for ASP.NET is:
<pre id="myPlaceholder" runat="server"></pre>
Then assign its value from code behind:
myPlaceholder.InnerHtml = MyText;
As for your question "why does it use \r and \n" those are carriage return and line feed characters, aka newline characters - when you have such text:
line 1
line 2
Then code reading it will give: line1\nline2 or line1\r\nline2 depending on how it's stored exactly.