Resize Grid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a good way to loop through each column of a grid and resize to fit
the longest record? Currently, the grid only contains one record with 8
columns.

Thanks
 
Try cycling through each column, keep track of the largest text width, and
set the column width to this largest value. You can use the DataGrid's
CreateGraphics method to obtain a Graphics object, then the MeasureString
method to determain the size of the text.

Hope this helps.

-Noah Coad
Microsoft MVP [.NET/C#]
 
Back
Top