TextBoxColumn - MultiLine, Wrap Text, Vertical Size

5 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
    Admin
    Dess avatar
    1841 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
    15 posts
    Member since:
    Jan 2017

    Posted 17 Apr 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
    Admin
    Dess avatar
    1841 posts

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