title: DataGridView: How to make some cells unselectable?
body: <p>How can I make some cells in DataGridView unselectable?</p>
  
  <p>By 'unselectable' I mean: It cannot be selected in any way and trying to select it won't unselect any other cell.</p>
  
  <p>I don't mean <code>ReadOnly</code>. My cells already have this property as true.</p>
  
  <p><code>DataGridView.MultiSelect</code> needs to be false.</p>
  
  <p>Thanks to JYL's answer I wrote a code:  </p>
  
  <pre><code>    private int selectedCellRow = 0;
      private int selectedCellColumn = 0;
  
      private void grid_CellStateChanged(object sender, DataGridViewCellStateChangedEventArgs e)
      {
          if (e.Cell == null || e.StateChanged != DataGridViewElementStates.Selected)
                  return;
  
          if (e.Cell.RowIndex == 0 || e.Cell.ColumnIndex == 0 || e.Cell.RowIndex == 1 &amp;&amp; e.Cell.ColumnIndex == 1)
          {
              e.Cell.Selected = false;
              grid.Rows[selectedCellRow].Cells[selectedCellColumn].Selected = true;
          }
          else
          {   
              selectedCellRow = e.Cell.RowIndex;
              selectedCellColumn = e.Cell.ColumnIndex;
          }
  
          //this was only for seeing what is happening
          //this.Text = selectedCellRow + " " + selectedCellColumn;
      }
  </code></pre>
  
  <p>But this leads to StackOverflow. What condition and where I need to put to prevent that?</p>