2013-10-03 47 views
0

我正在使用工作表保護IWorksheet.ProtectContents。如果我嘗試更改某些內容,則會顯示以下消息:「啓用保護時鎖定的單元格不能修改」。那麼是否有方法可以更改此消息的文本和標題或隱藏它?我如何更改錯誤信息?

回答

1

您可以處理WorkbookView。 ShowError(...)事件,這將使您有機會防止某些錯誤消息彈出或提供您自己的自定義消息。例如:

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