title: Datagridview Column width
body: <p><img src="https://i.stack.imgur.com/tYjcS.jpg" alt="enter image description here">I have problem related to datagridview in Winform.</p>
  
  <p>I have a list of table names in my left panel. When I click on Table I show the table content in right panel. I am showing data in a datagridview by fetching data and assigning datasource to dgv.</p>
  
  <p>I am setting following property to dgv.</p>
  
  <pre><code>dgTemp.Dock = DockStyle.Fill;
  dgTemp.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
  dgTemp.AutoSize = true;
  dgTemp.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
  dgTemp.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
  dgTemp.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  dgTemp.ReadOnly = true;
  dgTemp.AutoGenerateColumns = true;
  dgTemp.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  dgTemp.AllowUserToAddRows = false;
  </code></pre>
  
  <p>My problem is there can be any number of columns in Datasource I am assigning to dgv. So if there are very few number of columns (say 1 or 2) the dgv size stands very small and the empty space on right side give very ugly look.
  I can't use auto <code>autosizecolumnmode</code> to <code>fill</code> since when there is more columns all columns get shrink and expanding columns dont give me Scroll at bottom</p>
  
  <p>so My requirement is</p>
  
  <ol>
  <li>All space in datagridview should be filled. (should cover all area)</li>
  <li>When there is more column, there should appear scroll, so it give better look</li>
  </ol>
  
  <p>are there any events or properties which I can use ??</p>
  
  <p>Thanks in anticipation.</p>