You could get the resolution by
int screenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
int screenHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
And then use an if-clause to set AutoSizeColumnsMode-Property.
Like this:
private void getScreenResolution()
{
int screenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
int screenHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
}
private void setAutoSizeColumnsMode()
{
if (screenWidth <= 1680 || screenHeight <= 768)
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
else
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
}