Max Meleshko
Max Meleshko

Reputation: 43

How can i change Error message?

I'm using worksheet protection IWorksheet.ProtectContents. If i try to change something there is message: "Locked cells cannot be modified when protection is enabled". So is there a way to change text and title of this message or though hide it?

Upvotes: 1

Views: 541

Answers (1)

Tim Andersen
Tim Andersen

Reputation: 3184

You can handle the WorkbookView.ShowError(...) event, which would give you the chance to prevent certain error messages from popping up or provide your own custom message. Example:

private void workbookView_ShowError(object sender, SpreadsheetGear.Windows.Controls.ShowErrorEventArgs e)
{
    if (e.Message == "Locked cells cannot be modified when protection is enabled.")
    {
        MessageBox.Show("My custom message");
        e.Handled = true;
    }
}

Upvotes: 2

Related Questions