title: ArgumentOutOfRange Exception in c#
body: <p>I'm trying to access column name of the selected row in DataGridView control in windows form, but I'm getting <strong>ArgumenOutOfRange</strong> exception of the following code:</p>
  
  <pre><code>MessageBox.Show(dataGridView1.SelectedColumns[dataGridView1.CurrentCell.ColumnIndex].ToString());
  </code></pre>
  
  <p>Producing:</p>
  
  <pre><code>ArgumentOutOfRangeException was unhandled
  
  Index was out of range. Must be non-negative and less than the size of the collection.
  Parameter name: index
  </code></pre>
  
  <p>Could anyone please tell me how can I overcome from this error?</p>