Wrap Text In Column....HOW?!

5 posts, 0 answers
  1. Christopher
    Christopher avatar
    3 posts
    Member since:
    Jan 2009

    Posted 20 Mar 2009 Link to this post

    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.
  2. Nick
    Admin
    Nick avatar
    767 posts

    Posted 20 Mar 2009 Link to this post

    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.
  3. Barry Harkness
    Barry Harkness avatar
    4 posts
    Member since:
    Feb 2006

    Posted 27 Jan 2010 Link to this post

    Nick, how do you wrap text in a multi-row grid using an HtmlViewDefinition?
  4. Nick
    Admin
    Nick avatar
    767 posts

    Posted 01 Feb 2010 Link to this post

    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.
  5. Nick
    Admin
    Nick avatar
    767 posts

    Posted 01 Feb 2010 Link to this post

    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.
Back to Top