how to print the string in next line in wpf - c#

Window.Content = "Chandru" + "Guna" + "Kalai";
when i run this program the result like this ChandruGunaKalai.
so i want to print the each string value in line by line.
like this
Chandru
Guna
Kalai
please help me

Window.Content = "Chandru"+Environment.NewLine + "Guna" +Environment.NewLine+ "Kalai"+Environment.NewLine;

Environment.NewLine
Window.Content = "Chandru" + Environment.NewLine + "Guna" + Environment.NewLine + "Kalai";
That how to print a new line. Or you can use a StackPanel and set the Orientation to Vertical and put 3 seperate TextBlocks in it.

Related

Newline is not working in Xamarin.Android

I have string label = 20. I have added label prefix as "Goal" .in between i added \n . Two lines are not coming instead one line only appearing.I need Expected Output.
Expected Output:
Goal
20
ActualOutput:
Goal20
I have tried below methods, its not working
string label = Goal;
string cReturns = System.Environment.NewLine + "\n" + "\r";
string[] words = label.Split(cReturns.ToCharArray());
label = words +20;
or
label = "Goal\n20";
CAN ANYONE SUGGEST ME CORRECT ANSWER
Thanks
You try
instead of \n:
label = "Goal
20";
If i add drawtext in customview its not working
You could strip the \n and then offset the Y to get your text on the next line.
For Example :
string lab = "Goal";
canvas.DrawText(lab, 100, 100, p);
canvas.DrawText("20", 100, 150, p);
Effect.
using System.Environment.NewLine will help.
for example:
await MainPage.DisplayAlert("Connection Problem!", "Can't
access backEnd at the moment Please try again later!"
+ System.Environment.NewLine + ex.Message,
"OK");

Creating a newline in rich text box

I need help on creating a new line for my RichTextBox which I cant make work when using CheckBox.
It keeps overlapping instead of creating a newline of words.
Tried using the method of rtbdisplay.text = (display+envrionment.newline);
example from my code:
if (rbtnSmall.Checked == true)
{
rtbDisplay.Text = "displaytext".PadRight(20) + "size".PadRight(23) +
qty.ToString().PadRight(20) + StrongDummy;
}
Use the RichTextBox.Text property or the RichtTextBox.AppendText method to append a string with a newline.
myRichTextBox.Text += Environment.NewLine + "My new line.";
// Or
myRichTextBox.AppendText( Environment.NewLine + "My new line." );
You can use c# Environment.NewLine Property as described in http://msdn.microsoft.com/en-us/library/system.environment.newline%28v=vs.110%29.aspx. Or, the "old style" like #"\r\n".
Rgds,

Remove specific string from given URL

I have a URL example image1-resize.jpg, and I want to delete -resize and save image1.jpg in new variable.
How can I do that?
This is what I tried to do:
str1 += "<li><a href='#pic" + counter + "'><img src='admin/temp/hotelimg/" + temp_url.ToString() + "'/></a></li>";
string stt =temp_url.replace("-resize","");
str2 += "<div id='pic" + counter + "'><img src='admin/temp/hotelimg/" + stt.ToString() + "' width='550' height='370'/></div>";
This should do your job:
temp_url.replace("-resize","");
Note: You should always search before putting questions here, since sometimes its really easy and need just small research on it.

c# richtextbox only shows one line

been searching the internet for some time now and cant find a solution to my problem.
I'm trying to parse some lines into the richtextbox, but i only get one line instead of all of them. Heres a part of my code
foreach (var val in lineCountDict)
{
richTextBox2.Text = (val.Key + " - " + val.Value + " Drops -" +
((double)val.Value / (double)mobDeathCounter) * 100 + " % chance\n");
}
So when i run this i only get one line, any advice would be awesome
Thank you!
Of course you get one line since in each iteration you set richTextBox2.Text to the new value which replaces the old value.
Use richTextBox2.Text+="..."

adding space in texbox results when sending thru email

wassup guys im new to C# coding and i did a search but couldn't find exactly what im looking for. So i have a couple of text-boxes which holds string elements and integers
what i want to do is when these boxes are filled in i want to send a summary of the email to client/customer but the format is whats getting me.
(first, one) are strings equaling different text-boxes
my code is:
emailCompseTask.Body = first + one + Enviroment.NewLine +
second + two + Enviroment.NewLine
and so on problem is which i send thru email it shows something like this:
computer service25.00
instead of:
computer service 25.00
is there a way to add spacing to make this more presentable? or even a better way perhaps thanks in advance guys
try this :
emailCompseTask.Body = first + one + " "+ second + two ;
body takes as HTML input, check here for more spacing option.
I'm a bit confused, but you just want to add some spacing in the output? Just throw some spaces in there like you would another variable.
first + " " + one + Environment.NewLine
+ second + " " + two + Environment.NewLine;
You can use a table
string tableRow = #"<tr>
<td>{0}</td>
<td>{1}</td>
</tr>";
string htmlTable = #"<table>
{0}
</table>";
string rows = "";
// Can do this in a loop
rows += string.Format(tableRow, first, one);
rows += string.Format(tableRow, first, one);
emailComseTask.Body = string.Format(htmlTable, rows);

Categories

Resources