Spread for ASP.NET 表格控件在点击 Tab 键时,会在单元格之间切换焦点。顺序为 Cell[0,0],Cell[0,1],Cell[0,2].....Cell[0,5],Cell[1,0],Cell[1,1],Cell[1,2].....Cell[1,5]至最后一行最后一列,再返回至 Cell[0,0],如此往复循环。
本篇文章即阐述如何定制快捷键 Tab 点击事件,使焦点切换到其他控件。
C# 代码:
protected override void Render(HtmlTextWriter writer) { Table tb = this.FpSpread1.FindControl("viewPort") as Table; FpSpread1.Attributes.Add("onkeydown", "changefocus()"); base.Render(writer); }
JS 代码:
<script type="text/javascript"> function changefocus() { var button = this.document.getElementById("Button1"); event.cancelBubble = true; return false; button.focus(); } </script>
Demo 下载:VS2010 && Spread for ASP.NET 7.0 && .NET 4.0 && C#