Skip to content

Commit b02a5b9

Browse files
authored
Merge pull request #33 from unvell/fix/disallowPasteToReadonlyCell
Disable paste to read-only cells
2 parents e1bfec4 + 1554ea8 commit b02a5b9

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Editor/ReoGridEditor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,11 @@ public ReoGridEditor()
683683
MessageBox.Show(this, LangResource.Msg_Range_Intersection_Exception,
684684
"ReoGrid Editor", MessageBoxButtons.OK, MessageBoxIcon.Stop);
685685
}
686+
else if (e.Exception is OperationOnReadonlyCellException)
687+
{
688+
MessageBox.Show(this, LangResource.Msg_Operation_Aborted,
689+
"ReoGrid Editor", MessageBoxButtons.OK, MessageBoxIcon.Stop);
690+
}
686691
};
687692

688693
this.grid.CurrentWorksheetChanged += (s, e) =>

ReoGrid/Core/Clipboard.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public bool Paste()
263263
clipboardText = data.GetText();
264264
}
265265
}
266-
266+
267267
#elif ANDROID
268268

269269
#endif // WINFORM || WPF
@@ -306,6 +306,13 @@ public bool Paste()
306306
return false;
307307
}
308308

309+
// check whether the range to be pasted contains readonly cell
310+
if (this.CheckRangeReadonly(targetRange))
311+
{
312+
this.NotifyExceptionHappen(new OperationOnReadonlyCellException("specified range contains readonly cell"));
313+
return false;
314+
}
315+
309316
// check any intersected merge-range in partial grid
310317
//
311318
bool cancelPerformPaste = false;

0 commit comments

Comments
 (0)