title: Change padding for all cells in a single DataGridView column
body: <p>I have a DataGridView in my C# application.  Using the designer, I have set a <code>AlternatingRowsDefaultCellStyle</code> as well as the <code>DefaultCellStyle</code> properties on the DGV itself.  Both of those styles have a padding value of <code>0, 0, 5, 0</code>.  I have not set any custom styles for any of the DGV columns from the <code>Edit Columns</code> menu in the DataGridView Tasks add-in.</p>
  
  <p>There is one column in the DGV that is an image column that I draw a small graph in for each row.  I would like to remove the padding from all cells in this column so there is no padding applied to the cell which leaves some whitespace at the end of the graph.</p>
  
  <p>Each of the following things I have tried do not remove the padding from any cells in the column, but also don't throw any exceptions.</p>
  
  <pre><code>// first attempt
  // taken from http://social.msdn.microsoft.com/Forums/eu/winforms/thread/a9227253-8bb4-429a-a700-8a3a255afe4d
  deviceGrid.Columns["GProduction"].DefaultCellStyle.Padding = new Padding(0);
  
  // second attempt
  DataGridViewCellStyle style = deviceGrid.Columns["Graph"].DefaultCellStyle; // also tried Clone()
  style.Padding = new Padding(0);
  deviceGrid.Columns["GProduction"].DefaultCellStyle = style;
  
  // third attempt
  DataGridViewColumn col = deviceGrid.Columns["Graph"];
  DataGridViewImageCell icell = new DataGridViewImageCell();
  icell.Style.Padding = new Padding(0);
  col.CellTemplate = icell;
  </code></pre>
  
  <p>I suspect that maybe the <code>DefaultCellStyle</code> padding from the DataGridView itself is overriding the default cell style I am trying to set for the column, but if that is the case, what do I need to do to prevent this?</p>
  
  <p><strong>SOLUTION:</strong><br>
  After following the <a href="http://msdn.microsoft.com/en-us/library/1yef90x0.aspx" rel="noreferrer">link</a> provided by jmh_gr I found the problem was that the <code>DefaultCellStyle</code> for the DataGridView itself is inherited LAST on the cell so I had to remove the padding from the DGV properties, and apply it to all the columns except the one I didn't want padding on.</p>