Search code examples
spreadsheetgear

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?


Solution

  • 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;
        }
    }