title: How to make an excel cell ReadOnly using C#?
body: <pre><code>Range range= (Range)this.workSheet.Cells[1,1];
  range.AllowEdit = false;
  </code></pre>
  
  <p>When I set the <strong><code>AllowEdit</code></strong> property to false, a compile error will show:</p>
  
  <blockquote>
    <p>Error: Property or indexer
    'Microsoft.Office.Interop.Excel.Range.AllowEdit' cannot be assigned to
    -- it is read only</p>
  </blockquote>
  
  <p>How can I set the range of cells to be Read Only?</p>
  
  <p>When I am using validation for this range I got Some exception on my CellContentChanged Event .</p>
  
  <p>Here is the code which is in CellContentChanged:</p>
  
  <pre><code>   var updater = new Action&lt;StyleColorItem&gt;(
             item =&gt;
             {
                var editedItem = _taskViewModel.TrackedItems.First(it =&gt; it.Id == item.Id); 
              // Above line I am getting the exception like "Sequence contains no matching element"
                 editedItem.Update(item);'
             });
  </code></pre>