Donate

How To Wrap Text In A DataGridViewColumn

Given that you have data such as comments/notes/description/address that would comprise at least hundreds of characters and you want to show them on the DataGridView control, you will notice that the text is concatenated and replaced with ellipses.
Wrap Text In A DataGridViewColumn
In order to achieve wrapping of text in a DataGridView cell, I achieved it using these steps.
1. Change the WrapMode value to True of a DataGridViewTextBoxColumn's DefaultCellStyle. Wrap Text In A DataGridViewColumn
2. In my DataBindingComplete event of the DataGridView, set the AutoSizeRowsMode of the DataGridView to AllCells.
Wrap Text In A DataGridViewColumn
C# Code
private void dgvFormat_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
 dgvFormat.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
}

That's it.. :-)

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.

Invalid nested tag div found, expected closing tag input