title: Set the precision for double/float/decimal in System.Windows.Forms.DataGrid
body: <p>How can I set the precision for a data column that holds double, float or decimal numbers in a System.Windows.Forms.DataGrid?</p>
  
  <p>For DataGridView there is <a href="https://stackoverflow.com/questions/11229590/how-to-format-a-column-with-number-decimal-with-max-and-min-in-datagridview">How to format a column with number decimal with max and min in DataGridView?</a>, for example.</p>
  
  <p>I want <code>0.0100000001</code> to be displayed as <code>0.01</code>, for example, which would be precision of 2 digits after the decimal mark. I want to avoid them looking like this, where float and double use the scientific notation:</p>
  
  <p><a href="https://i.stack.imgur.com/6ZP7U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6ZP7U.png" alt="enter image description here"></a></p>
  
  <p>The code I used to fill the table is:</p>
  
  <pre><code>var table = new DataTable();
  table.Columns.Add("double");
  table.Columns.Add("float");
  table.Columns.Add("decimal");
  table.Columns[0].DataType = typeof(double);
  table.Columns[1].DataType = typeof(float);
  table.Columns[2].DataType = typeof(decimal);
  table.Rows.Add(new object[] { 0.00000000000423, 0.00000000000423, 0.00000000000423 });
  dataGrid1.DataSource = table;
  </code></pre>
  
  <p><em>Note: I know DataGrid is obsolete, but I'm dealing with legacy code, please don't comment to tell me to use DataGridView - it doesn't help me.</em> </p>