Spread 中默认点击左上角的表角(Corner)会选中Spread的全部单元格,有时候我们不希望这种选中行为,需要屏蔽该操作,此时我们可以使用下面的代码来进行屏蔽:
第一步:
重写页面的 Render 方法,并为 Corner 添加一个 onmousedown 的客户端事件
- protected override void Render(HtmlTextWriter writer)
- {
- WebControl corner = this.FpSpread1.FindControl("corner") as WebControl;
- corner.Attributes.Add("onmousedown", "return CornerClick()");
- base.Render(writer);
- }
复制代码
- Protected Overrides Sub Render(writer As HtmlTextWriter)
- Dim corner As WebControl = TryCast(Me.FpSpread1.FindControl("corner"), WebControl)
- corner.Attributes.Add("onmousedown", "return CornerClick()")
- MyBase.Render(writer)
- End Sub
复制代码
第二步:
添加客户端 JS 代码
- <script type="text/javascript">
- function CornerClick() {
- event.cancelBubble = true;
- event.returnValue = false;
- return false;
- }
- </script>
复制代码 |
|