感谢版主的帮忙,代码生效了,可是出现了一个问题,因为这段代码是绑定在一个文本框的keydown事件里的,一旦调用,焦点就会失去,我就算用代码强制将焦点移回去,可是之前用户KEYDOWN时输入或者删除文本框内容的这个......
simonshen 发表于 2012-7-20 10:11:00
我的测试代码如下,请楼主测试,如果没有解决问题,请楼主发Demo到论坛调试:
- <head runat="server">
- <title></title>
- <script language="javascript" type="text/javascript">
- // <![CDATA[
- function Button1_onclick() {
- for (var i = 0; i < 3; i++) {
- FpSpread1.SetActiveCell(i, 0);
- FpSpread1.Delete();
- }
- }
- // ]]>
- function funkeydown() {
- for (var i = 0; i < 3; i++) {
- FpSpread1.SetActiveCell(i, 0);
- FpSpread1.Delete();
- }
- var textbox = this.document.getElementById("Text1");
- textbox.focus();
- }
- </script>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="Black" BorderStyle="Solid"
- BorderWidth="1px" Height="200" Width="400">
- <CommandBar BackColor="Control" ButtonFaceColor="Control" ButtonHighlightColor="ControlLightLight"
- ButtonShadowColor="ControlDark">
- </CommandBar>
- <Sheets>
- <FarPoint:SheetView SheetName="Sheet1">
- </FarPoint:SheetView>
- </Sheets>
- </FarPoint:FpSpread>
- <input id="Button1" type="button" value="button" onclick="return Button1_onclick()" />
- <input onkeydown="funkeydown()" id="Text1" type="text" />
- </div>
- </form>
- </body>
- </html>
复制代码 |