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

Wrap Text In Column....HOW?!

4 Answers 198 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Christopher
Top achievements
Rank 1
Christopher asked on 20 Mar 2009, 03:09 PM
All I want to do is have a paragraph of text in a cell wrap.  Why is this so hard with your grid control.  Never before have I had so much trouble.  I see the properties and options there (wordwrap, colwidth, rowheight, etc. etc. etc.).  No matter what I do, nothing wraps.

4 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 20 Mar 2009, 05:59 PM
Hello Christopher,

Thank you for your question.

Please set the WrapText property to each column. For instance:

private void Form1_Load(object sender, EventArgs e) 
       this.radGridView1.Columns[0].WrapText = true

Do not hesitate to write me back if you have further questions.

Sincerely yours,
Nick
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Barry Harkness
Top achievements
Rank 1
answered on 27 Jan 2010, 05:51 PM
Nick, how do you wrap text in a multi-row grid using an HtmlViewDefinition?
0
Nick
Telerik team
answered on 01 Feb 2010, 09:33 AM
Hello Barry Harkness,

Thank you for contacting us. It is the same in both views but there is a bug so just setting a property to the column does not work as its value does not propagate properly to the cell. You can work-around the issue by manually setting the text wrapping to the cell in ViewCellFormatting:

void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
     if (e.CellElement.ColumnInfo.WrapText)
     {
         e.CellElement.TextWrap = true;
     }
}
 
The code above checks the column and propagates the text wrapping to the visual cell element.

We are going to fix the issue in our next official release (Q1 2010) expected at the beginning of March.

Greetings,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Nick
Telerik team
answered on 01 Feb 2010, 10:02 AM
Hi Barry Harkness,

I created the work-around with our development version, but the property TextWrap is not exposed in Q3 2009 SP1 so here is another work-around (unfortunately there is more code now):

void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e)
{
  
   if (e.CellType == typeof(GridDataCellElement))
   {
  
       e.CellType = typeof(CustomDataCell);
   }
}
  
public class CustomDataCell: GridDataCellElement
{
  
public CustomDataCell(GridViewColumn column, GridRowElement row)
: base(column, row)
{
}
  
protected override Type ThemeEffectiveType
{
   get
   {
       return typeof(GridDataCellElement);
   }
}
  
public override StringFormat PaintTextFormat
{
  
get
{
   StringFormat sf = base.PaintTextFormat;
   sf.FormatFlags &= ~StringFormatFlags.NoWrap;
   return sf;
}
  
}
}

Best wishes,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Christopher
Top achievements
Rank 1
Answers by
Nick
Telerik team
Barry Harkness
Top achievements
Rank 1
Share this question
or