I have a winform applicaction with a DataGridView in Virtual mode, everything is working great! the only problem is that when i hit double click en a column divider, the control is trying to fit the column width to all cells, not only the displayed or visible! And obviously that hangs the app.
I have try all kind of configurations
AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;
AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
Everything!, settings in the datagrid and in each column! and nothing works
Any idea?
The final result is: User being able to resize the columns, but not by giving double click en de column border!.. i dont care if it doesnt fit at all.
You should process ColumnDividerDoubleClick this way:
private void datagridview_ColumnDividerDoubleClick(object sender, DataGridViewColumnDividerDoubleClickEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
datagridview.AutoResizeColumn(e.ColumnIndex, DataGridViewAutoSizeColumnMode.DisplayedCells);
}
e.Handled = true;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With