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

TextBoxColumn - MultiLine, Wrap Text, Vertical Size

6 Answers 1085 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Doug
Top achievements
Rank 1
Doug asked on 24 Jul 2013, 08:29 PM
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

6 Answers, 1 is accepted

Sort by
0
Doug
Top achievements
Rank 1
answered on 25 Jul 2013, 02:50 PM
I withdraw that question.  I was too busy looking at column/cell properties and completely forgot about the AutoSizeRows property of the GridView itself.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Jul 2013, 04:18 PM
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 >>
0
Abdul
Top achievements
Rank 1
answered on 17 Apr 2017, 01:41 PM

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

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Apr 2017, 11:29 AM
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.
0
Orly
Top achievements
Rank 1
answered on 30 Sep 2019, 12:01 PM
What about if i am worked with telerik:GridBoundColumn and i want to set some column multiline. What i have to do? Thanks!!!
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 30 Sep 2019, 12:16 PM

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.
Tags
GridView
Asked by
Doug
Top achievements
Rank 1
Answers by
Doug
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Abdul
Top achievements
Rank 1
Orly
Top achievements
Rank 1
Share this question
or