This is a migrated thread and some comments may be shown as answers.

Text with carriage return

2 Answers 259 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Maarten
Top achievements
Rank 1
Maarten asked on 03 Aug 2012, 11:13 AM
Hi,

One of the grids in our application displays a field which can contain carriage returns (\r\n). For the grid the multiline and wrap properties are set to false and the ellipse property is set to true, since we want the text to be single line and ellipsed.

However the colum does take the carriage return into account and tries to squeeze the both lines into one line (see screenshot). Each line individually is however ellipsed.

What is the best approach to prevent the column to ignore the carriage returns, in order to have one single ellipsed line? Off course without removing the carriage return from the string itself.

Many Thanks,
Maarten

2 Answers, 1 is accepted

Sort by
0
Accepted
Svett
Telerik team
answered on 07 Aug 2012, 01:16 PM
Hi Maarten,

GDI+ in Winforms recognizes and obeys the special symbols when painting. Hence, you should modify the string used for rendering to achieve the desired scenario. With the following approach, you are not changing the actual value and you are just modifying the rendered text:
private void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
    string text = e.CellElement.Text;
    e.CellElement.Text = text.Replace(Environment.NewLine, " ");
}

I hope this helps.

Regards,
Svett
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Maarten
Top achievements
Rank 1
answered on 10 Aug 2012, 11:06 AM
Thx!
Tags
GridView
Asked by
Maarten
Top achievements
Rank 1
Answers by
Svett
Telerik team
Maarten
Top achievements
Rank 1
Share this question
or