Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7949063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:53:33+00:00 2026-06-04T01:53:33+00:00

Range range= (Range)this.workSheet.Cells[1,1]; range.AllowEdit = false; When I set the AllowEdit property to false,

  • 0
Range range= (Range)this.workSheet.Cells[1,1];
range.AllowEdit = false;

When I set the AllowEdit property to false, a compile error will show:

Error: Property or indexer
‘Microsoft.Office.Interop.Excel.Range.AllowEdit’ cannot be assigned to
— it is read only

How can I set the range of cells to be Read Only?

When I am using validation for this range I got Some exception on my CellContentChanged Event .

Here is the code which is in CellContentChanged:

   var updater = new Action<StyleColorItem>(
           item =>
           {
              var editedItem = _taskViewModel.TrackedItems.First(it => it.Id == item.Id); 
            // Above line I am getting the exception like "Sequence contains no matching element"
               editedItem.Update(item);'
           });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:53:34+00:00Added an answer on June 4, 2026 at 1:53 am

    There is no way to make a cell read-only in excel.

    What you can do in your c# code is, define a cell that is going to be “read-only” in a variable or a list, subscribe to the SheetChange event , in the SheetChange event, if that cell gets changed, simply undo that change.

    Example
    private List readOnlyCells = new List();

    private void OnActiveSheetCellChange(object changedSheet, Excel.Range changedCell)
    {
      if (readOnlyCells.Contains(changedCell))
          changedCell.Value = string.Empty;
          //.... YOUR CODE
    

    Update

    Another alternative is to use Data Validation:

    changedCell.Validation.Add(Excel.XlDVType.xlValidateCustom, Type.Missing, Type.Missing, "\"\"");
    

    Using it you will have less control and the cell will simply not accept any input.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i read data from an excel file with this code Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet; Microsoft.Office.Interop.Excel.Range range;
Say I have a Range object for cells A1:A10 in my worksheet. These cells
I am reading Excel worksheet data using C# and Microsoft.Office.Interop. The sheet contains some
Question in short : this line: doc.InlineShapes.AddOLEObject(Excel.Chart.8); // doc is a Microsoft.Office.Interop.Word.Document object opens
I'm building a range between two numbers (floats) and I'd like this range to
I want to make sure a string has only characters in this range [a-z]
Consider this Python snippet: for a in range(10): if a == 7: pass if
I have this following IEnumerable LINQ query: var query = from p in Enumerable.Range(2,
This query selects all the unique visitor sessions in a certain date range: select
Thought my range of search options would easily find this. I wish to combine

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.