手动添加WorkSheet后Sheet被锁定,设置Protect=false也不行
手动添加WorkSheet后Sheet被锁定,设置Protect=false也不行。关键代码如下
grdCustoms.Sheets.Clear();
grdCustoms.Sheets.Add(sheet1);
grdCustoms.Sheets.Add(sheet2);
grdCustoms.Sheets.Add(sheet3);
grdCustoms.Sheets.Add(sheet4);
sheet1.Protect = false;
sheet1.SelectionPolicy = SelectionPolicy.MultiRange;
this.grdCustoms.AutoRefresh = false;
this.grdCustoms.SuspendCalcService();
this.grdCustoms.SuspendEvent();
sheet1.SelectionUnit = SelectionUnit.Cell;
var v = DataValidator.CreateListValidator("网络,电视,广告,门店");
for (int i = 0; i < 10; i++)
{
for (int n = 0; n < 20; n++)
{
sheet1.Rows.Locked = false;
sheet1.Cells.Locked = false;
sheet1.SetValue(i, n, i * n);
}
sheet1.Cells.DataValidator = v;
}
this.grdCustoms.ResumeEvent();
this.grdCustoms.ResumeCalcService();
this.grdCustoms.AutoRefresh = true;
问题解决了,不是控件的问题,是所在窗体的MouseMove事件中锁定了鼠标,所以看似lock的效果
private void ribbonView_MouseMove(object sender, MouseEventArgs e)
{
if (isMouseDown && e.GetPosition(this).Y < 100)
{
this.ribbonView.CaptureMouse();
Point currentPos = e.GetPosition(this);
Point endPoint = new Point(cX, cY);
this.Left += currentPos.X - endPoint.X;
this.Top += currentPos.Y - endPoint.Y;
}
else
{
this.ribbonView.ReleaseMouseCapture();
}
} 回复 2楼sucsy的帖子
感谢你的详细代码以及对该问题的反馈。
该反馈可为以后用户提问作为参考。
赠送350金币作为奖励。
页:
[1]