0

I have a grid of 5 columns and n rows. Row 0 is my header row. Each cell of the header row would contain text in German. As my cell width is fixed, trying to determine the row height so I can set that and display complete text in each cell.

Font i am using is Consolas of size 10

For a given string I am calculating the size using TextRenderer.MeasureText and getting the height and width of each string. Based on the max height, i set the header row height. This height value obtained is not always accurate as I observe some text that is cut off.

Is there a better approach to setting the height using the input string and the font and font size that is used? In addition can i get away from importing the Forms class as I would like to move this into a library?

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
user721264
  • 477
  • 2
  • 8
  • 22
  • Most grids calculate the row height automatically. You should be able to set [padding and margins](https://msdn.microsoft.com/en-us/library/ms751709%28v=vs.110%29.aspx) as well. Why do you need to calculate it yourself? Which grid are you using? – Panagiotis Kanavos May 26 '15 at 15:55
  • It is a grid written by the customer, haven't decompiled their library to see what they have underneath the hood – user721264 May 26 '15 at 16:03

0 Answers0