DataGridView autosizing rows with Wrapmode set lowers performance
significantly
So, I have a DataGridView that has row headers disabled, wrapmode set for
multiline cell text and autosize of rows to adjust to the multiline text.
In code:
view.RowHeadersVisible = false;
view.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
view.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
The problem is that setting the AutoSizeRowsMode property makes the view
update REALLY slow, compared to not having it set.
Below is a link to more or less the same problem:
http://brianseekford.com/index.php/2010/04/01/datagridview-bug-with-the-autowrap-and-the-autorowsize-not-resizing-rows-on-scroll/
Their solution:
view.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
view.Scroll +=new ScrollEventHandler(view_Scroll);
private void view_Scroll(object sender, ScrollEventArgs e)
{
//Workaround for datagrid view bug.
((DataGridView)sender).AutoSizeRowsMode =
DataGridViewAutoSizeRowsMode.DisplayedHeaders;
((DataGridView)sender)AutoSizeRowsMode =
DataGridViewAutoSizeRowsMode.DisplayedCells;
}
Now, the problem is that the row headers are disabled, and therefore my
program just crashes when scrolling.
I hope anyone has a solution or atleast some idea to what i can do.
No comments:
Post a Comment