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#]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top