Friday, December 14, 2012

Add line breaks for a text and assign it to label

I would like to show how we can display a longer text with line breaks, actually the string is as follows



Anna’s crusade gets a Gen Singh boost

29 Indian fishermen still languish in Iran prison

Shiromani Akali Dal sarpanch held for slapping Sanaur
 superintendent of panchayat department

Jats to review Delhi march schedule

Doctor in the eye of the storm

the exact way I would like to print my text on the label, so I write as follows


using (StringReader reader = new StringReader(mymessage)) // here mymessage is your variable
            {
                string line;
                labelmsg.Text = string.Empty;
                while ((line = reader.ReadLine()) != null)
                {
                    line.Trim();
                   labelmsg.Text += line + "
";
                }
            }

here come the label text as follows















If any other easier method or queries let me know.


No comments:

Post a Comment

Popular Posts