I have a simple form with a DataGridView element. In the constructor, grid columns are added and the DataTable is set. When I call AutoResizeColumns (), it does not resize the columns, as it would when called, for example. event buttons. The code looks like this (simplified):
public MyDialog()
{
InitializeComponent();
dgv.Columns.AddRange(SomeClass.MyColumns);
dgv.DataSource = SomeClass.Table;
dgv.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
AutoResizeColumns () works in general, but not at this point. By the way, I need this to implement such behavior as requested / described here . Any ideas?
source
share