Posted By

Sootah on 02/12/11


Tagged


Versions (?)

dataGrid_Resize - Automatically resize columns as DataGridView is resized


 / Published in: C#
 

  1. public double dataGridTitleSizeRatio = 3.35; //3.563492063492063
  2. public double dataGridSearchTermSizeRatio = 5.98; //5.986666666666667
  3. public double dataGridURLSizeRatio = 2.27; //2.273417721518987
  4.  
  5. private void dataGrid_Resize(object sender, EventArgs e)
  6. {
  7. dataGrid.Columns[0].Width = Convert.ToInt32((Convert.ToDouble(dataGrid.Width) / dataGridTitleSizeRatio));
  8. dataGrid.Columns[2].Width = Convert.ToInt32((Convert.ToDouble(dataGrid.Width) / dataGridSearchTermSizeRatio));
  9. dataGrid.Columns[3].Width = Convert.ToInt32((Convert.ToDouble(dataGrid.Width) / dataGridURLSizeRatio));
  10. }

Report this snippet  

You need to login to post a comment.