Thank you,
Gary
6 Answers, 1 is accepted
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
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 >>
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
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
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