How to do that would automatically change the size of the column height, depending on the amount of text in it?
4 Answers, 1 is accepted
0
Accepted
0
Hi guys,
That is correct, the AutoSizeRows is what you need in order to size your rows according to their content.
@Mahmoud - thank you for your community effort. I have updated your Telerik Points as a token of appreciation.
Regards,
Stefan
Telerik
That is correct, the AutoSizeRows is what you need in order to size your rows according to their content.
@Mahmoud - thank you for your community effort. I have updated your Telerik Points as a token of appreciation.
Regards,
Stefan
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Stas
Top achievements
Rank 1
answered on 15 Mar 2015, 12:45 PM
If the entered text is not multiline it does not work
0
Hello Stas,
Thank you for writing.
You would also need to handle the CellFormatting event of the grid and set the TextWrap property of the CellElement argument to true. Please see my code snippet below:
I am also sending you gif file of the result on my end.
I hope this information is useful. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
Thank you for writing.
You would also need to handle the CellFormatting event of the grid and set the TextWrap property of the CellElement argument to true. Please see my code snippet below:
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
GridViewTextBoxColumn textBoxColumn =
new
GridViewTextBoxColumn(
"TextBoxColumn"
);
radGridView1.MasterTemplate.Columns.Add(textBoxColumn);
this
.radGridView1.Rows.Add(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor non nibh sit amet tempus. Suspendisse potenti."
);
this
.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this
.radGridView1.AutoSizeRows =
true
;
this
.radGridView1.CellFormatting += radGridView1_CellFormatting;
}
private
void
radGridView1_CellFormatting(
object
sender, CellFormattingEventArgs e)
{
if
(e.CellElement
is
GridDataCellElement && e.CellElement.ColumnInfo.Name ==
"TextBoxColumn"
)
{
e.CellElement.TextWrap =
true
;
}
}
}
I am also sending you gif file of the result on my end.
I hope this information is useful. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.