Reputation: 523
I build an Excel application using C# in my WPF application. In that Excel I created one Header Row. Now I want to make Header row cells as uneditable cells and it should revert back to the previous value. For that, I am using Validation for header row to satisfy this condition . When I am going to change the any cell in the Header row It will show an alert box. The Alert box icon is not fine and also its having some other buttons like Retry, Cancel and Help.
1) Now I want to know How to get that Alert Box by using some better format(Icon Should be an Information image and It Should have Retry and cancel button.No need for Help Button) .
(or)
2) I dont want to show the alert box But the new modified value has to revert to the previous value. The cell has to uneditable.
(or)
3) Can we use lock the particular range of cells?
My Code for that Condition is:
public static void FormatAsHeader(this Range range, bool wrapContent)
{
.
.
range.Validation.Add(XlDVType.xlValidateCustom, Type.Missing, Type.Missing, "\"\"");
}
Can any one please tell me the solution of this problem?
Upvotes: 1
Views: 5651
Reputation: 1266
You should be able to do: range.Locked = true;
and then call Protect()
on your worksheet.
See Range.Locked
and WorkSheet.Protect
.
Upvotes: 4