找回密码
 立即注册

QQ登录

只需一步,快速开始

sucsy

高级会员

3

主题

8

帖子

1931

积分

高级会员

积分
1931

活字格认证

最新发帖
sucsy
高级会员   /  发表于:2015-5-25 11:12  /   查看:5160  /  回复:2
手动添加WorkSheet后Sheet被锁定,设置Protect=false也不行。
关键代码如下

  1.             grdCustoms.Sheets.Clear();
  2.             grdCustoms.Sheets.Add(sheet1);
  3.             grdCustoms.Sheets.Add(sheet2);
  4.             grdCustoms.Sheets.Add(sheet3);
  5.             grdCustoms.Sheets.Add(sheet4);


  6.             sheet1.Protect = false;
  7.             sheet1.SelectionPolicy = SelectionPolicy.MultiRange;

  8. this.grdCustoms.AutoRefresh = false;
  9.             this.grdCustoms.SuspendCalcService();
  10.             this.grdCustoms.SuspendEvent();

  11.             sheet1.SelectionUnit = SelectionUnit.Cell;

  12.             var v = DataValidator.CreateListValidator("网络,电视,广告,门店");
  13.             

  14.             for (int i = 0; i < 10; i++)
  15.             {
  16.                 for (int n = 0; n < 20; n++)
  17.                 {
  18.                     sheet1.Rows[i].Locked = false;
  19.                     sheet1.Cells[1, n].Locked = false;
  20.                     sheet1.SetValue(i, n, i * n);                    
  21.                 }

  22.                 sheet1.Cells[i, 2].DataValidator = v;
  23.             }           


  24.             this.grdCustoms.ResumeEvent();
  25.             this.grdCustoms.ResumeCalcService();
  26.             this.grdCustoms.AutoRefresh = true;
复制代码

2 个回复

倒序浏览
sucsy
高级会员   /  发表于:2015-5-25 11:48:00
沙发
问题解决了,不是控件的问题,是所在窗体的MouseMove事件中锁定了鼠标,所以看似lock的效果
  1. private void ribbonView_MouseMove(object sender, MouseEventArgs e)
  2.         {
  3.             if (isMouseDown && e.GetPosition(this).Y < 100)
  4.             {
  5.                 this.ribbonView.CaptureMouse();
  6.                 Point currentPos = e.GetPosition(this);
  7.                 Point endPoint = new Point(cX, cY);
  8.                 this.Left += currentPos.X - endPoint.X;
  9.                 this.Top += currentPos.Y - endPoint.Y;
  10.             }
  11.             else
  12.             {
  13.                 this.ribbonView.ReleaseMouseCapture();
  14.             }
  15.         }
复制代码

评分

参与人数 1金币 +350 收起 理由
Alice + 350 提供代码,反馈解决问题方案

查看全部评分

回复 使用道具 举报
Alice
社区贡献组   /  发表于:2015-5-25 13:59:00
板凳
回复 2楼sucsy的帖子

感谢你的详细代码以及对该问题的反馈。
该反馈可为以后用户提问作为参考。
赠送350金币作为奖励。
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部