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