Datagridview automatic row size does not get small enough

Viewed 65

I have a datagridview in virtual mode, with AutoSizeRowsMode = DisplayedCellsExceptHeaders. The row sizes are determined automatically by datagridview and this works fine. Some cells have multi-line text. I am adding a zoom-in/zoom-out feature, in which I increase and decrease the font size of the cells, using dataGridView1.DefaultCellStyle.Font = new Font(Font.FontFamily, newFontSize, Font.Style, Font.Unit); The original font size is 8.25. When I increase the font size the row sizes increase, which works perfectly. But when I make the font size smaller than the original font size, then the cell text is drawn smaller but the row size does not get smaller. It seems like the rows have a minimum height of 20. Setting dataGridView1.RowTemplate.MinimumHeight = 3; does not help. Setting dataGridView1.DefaultCellStyle.Padding = new Padding(0, 0, 0, 0); does not help. When I turn off AutoSizeRowsMode I can set the row heights to a small value but that is not a solution because the multi-line cells are clipped. How can I fix this?

0 Answers
Related