TextBoxColumn - MultiLine, Wrap Text, Vertical Size

7 posts, 0 answers
  1. Doug
    Doug avatar
    50 posts
    Member since:
    Jul 2012

    Posted 24 Jul 2013 Link to this post

    Can you make a row autosize or otherwise set the height so that all of the the text in the cell in a TextBoxColumn is visible?  For some of the rows, the text string is short.  For others, it will take four lines to contain the text.

    Thank you,
    Gary
  2. Doug
    Doug avatar
    50 posts
    Member since:
    Jul 2012

    Posted 25 Jul 2013 Link to this post

    I withdraw that question.  I was too busy looking at column/cell properties and completely forgot about the AutoSizeRows property of the GridView itself.
  3. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3559 posts

    Posted 29 Jul 2013 Link to this post

    Hello Gary,

    Thank you for contacting Telerik Support.

    You have found the correct answer. RadGridView.AutoSizeRows property gets or sets a value indicating whether row height in a RataGridView will expand for multiline cell text. If you want the entire text to be visible in the cell it should be set to true.

    Should you have further questions, I would be glad to help.

    Regards,
    Desislava
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  4. Abdul
    Abdul avatar
    27 posts
    Member since:
    Jan 2017

    Posted 17 Apr 2017 Link to this post

    Hello Dess,

    I am facing two issues.

    1.When i am typing in GridViewTextBoxColumn the text is not visible until leave from the cell.And it will see again i go to the same GridViewTextBoxColumn and when i am typing in the cell again. (I set the property that MultiLine is to true and AcceptsReturn is to true also Wrap Text is to true).Here I want to see everytime when i am typing in the cell.

    2.The RadGridView.AutoSizeRows property gets or sets a value indicating whether row height in a RadGridView will expand for MultiLine cell text at RadGridView.CellEndEdit.Am I right?I want Custom Size/Autosize for row when multiple lines of text while typing. ie;The height of row will increase when the according to the lines of text present in the GridViewTextBoxColumn.

    I hope you got the question.

    Regards

    ABDUL HAFEEL

  5. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3559 posts

    Posted 18 Apr 2017 Link to this post

    Hello Abdul, 

    Thank you for writing back. 

    The RadGridView.AutoSizeRows property controls whether row's height in a RadGridView will expand for multiline cell text. However, note that when a cell is in edit mode and you are typing in the editor, this value is not committed to the cell yet. That is why the row's height is not updated. You can find below a sample approach that demonstrates how to disable the rows auto sizing when the editor is activated and the row's height is adjusted by the MinHeight property: 
    public RadForm1()
    {
        InitializeComponent();
     
        this.radGridView1.Columns.Add("Text col");
        this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
     
        this.radGridView1.AutoSizeRows = true;
        this.radGridView1.Columns[0].WrapText = true;
     
        this.radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized;
        this.radGridView1.CellEndEdit += radGridView1_CellEndEdit;
    }
     
    private void radGridView1_CellEndEdit(object sender, GridViewCellEventArgs e)
    {
        this.radGridView1.AutoSizeRows = true;
    }
     
    private void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
    {
        this.radGridView1.AutoSizeRows = false;
        RadTextBoxEditor tbEditor = e.ActiveEditor as RadTextBoxEditor;
        if (tbEditor != null)
        {
            tbEditor.Multiline = true;
            tbEditor.AcceptsReturn = true;
            RadTextBoxEditorElement el = tbEditor.EditorElement as RadTextBoxEditorElement;
            if (el != null)
            {
                el.TextBoxItem.TextBoxControl.TextChanged -= TextBoxControl_TextChanged;
                el.TextBoxItem.TextBoxControl.TextChanged += TextBoxControl_TextChanged;
            }
        }
    }
     
    private void TextBoxControl_TextChanged(object sender, EventArgs e)
    {
        HostedTextBoxBase tb = sender as HostedTextBoxBase;
        if (tb != null)
        {
            this.radGridView1.CurrentRow.MinHeight = tb.Lines.Length * 16;
        }
    }

    Note that this is just a sample approach and it may not cover all possible cases. Feel free to modify it in a way which suits your requirement best.

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. Orly
    Orly avatar
    2 posts
    Member since:
    Sep 2019

    Posted 30 Sep 2019 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    What about if i am worked with telerik:GridBoundColumn and i want to set some column multiline. What i have to do? Thanks!!!
  7. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3559 posts

    Posted 30 Sep 2019 Link to this post

    Hello, Orly,   

    I would like to note that this forum thread is relevant for the Telerik UI for WinForms RadGridView. However, the GridBoundColumn is relevant for the grid from the ASP.NET AJAX suite. Feel free to post your inquiries in the relevant forum and thus the respective community will gladly assist you: https://www.telerik.com/forums

    Thank you for your understanding.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top