I have a datagridview in windows application form below which I put two buttons (one for zoom in and other for zoom out). Now when user press the zoom button I increase/decrease the font size inside the grid according to predefined ratio. It works fine i.e the font size reduces and increases but the only thing that not working is the size of cell or datagridview.
Every time the cell size remains fix. I want to resize my datagridview accordingly, currently i am using the following code but it doesn't work in my case :(
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
you should either switch the two lines:
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dataGridView1.AutoResizeColumns();
Or call it like this:
Either way you have to do this after you have changed the font.