hai how can we Adjust the column widths based on the displayed values in a datagrid in c# windows application?.
If you are using DataGridView as your datagrid control there's an AutoSizeColumns property that if set to true it will adjust columns widths automatically.
Well one approach is to set the attribute AutoSizeColumnsMode to "Fill" which will resize the columns dynamically in order to fill the extent of the grid. Then, for each column you can also specify the FillWeight (in "Edit Columns") in order to have a "weighted" resizing of the columns.
Otherwise you can set the default width for each column by setting the "Width" attribute in "Edit Columns"
If you want to do this programmatically at runtime, you can do it by calling
dataGridView1.Columns[...].Width = XX
You can do this by using MeasureString to compute the size of the text in each cell, and then take the maximum value.
You can find the code snippet to do this here - http://www.syncfusion.com/FAQ/windowsforms/faq_c44c.aspx#q877q