问题已经解决了,可以使用“EditStarting ”事件来处理- protected void BindData()
- {
- this.grdItems.ActiveSheet.CellChanged -= new EventHandler<CellChangedEventArgs>(ActiveSheet_CellChanged);
- this.grdItems.EditStarting -= new EventHandler<GrapeCity.Windows.SpreadSheet.UI.EditCellStartingEventArgs>(grdItems_EditStarting);
- this.grdItems.AutoRefresh = false;
- this.grdItems.SuspendCalcService();
- this.grdItems.SuspendEvent();
- CreateData();
- this.grdItems.ResumeEvent();
- this.grdItems.ResumeCalcService();
- this.grdItems.AutoRefresh = true;
- App.DoEvents();
- this.grdItems.ActiveSheet.CellChanged += new EventHandler<CellChangedEventArgs>(ActiveSheet_CellChanged);
- this.grdItems.EditStarting += new EventHandler<GrapeCity.Windows.SpreadSheet.UI.EditCellStartingEventArgs>(grdItems_EditStarting);
- }
- void grdItems_EditStarting(object sender, GrapeCity.Windows.SpreadSheet.UI.EditCellStartingEventArgs e)
- {
- if (e.Column == 8 || e.Column == 10)
- {
- e.Cancel = true;
- }
- else
- {
- Row row = grdItems.ActiveSheet.Rows[e.Row];
- if (row.Locked)
- {
- e.Cancel = !(e.Column == 1 || e.Column == 9);
- }
- }
- }
复制代码 |