找回密码
 立即注册

QQ登录

只需一步,快速开始

gls6316
高级会员   /  发表于:2016-10-20 11:19  /   查看:3317  /  回复:3
無題.png

3 个回复

倒序浏览
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-10-20 13:30:47
沙发
您好设置 FocusPosition

  1.             var ct = new CustomerCellType();
  2.             ct.FocusPosition = EditorFocusCursorPosition.End;
  3.             fpSpread1.ActiveSheet.Cells[1, 1].CellType = ct;
复制代码
回复 使用道具 举报
gls6316
高级会员   /  发表于:2016-10-20 15:49:58
板凳
dexteryao 发表于 2016-10-20 13:30
您好设置 FocusPosition

        private void spdOrder_EditChange(object sender, EditorNotifyEventArgs e)
        {
            try
            {
                FarPoint.Win.Spread.CellType.TextCellType celltype;
                int rowindex = spdOrder.Sheets[0].ActiveRowIndex;        // 当前行
                int columnindex = spdOrder.Sheets[0].ActiveColumnIndex; // 当前列

                if ((spdOrder.Sheets[0].Columns.Get(columnindex).CellType.NToString() == "TextCellType" &&
                    string.IsNullOrEmpty(spdOrder.Sheets[0].Cells.Get(rowindex, columnindex).CellType.NToString())) ||
                    spdOrder.Sheets[0].Cells.Get(rowindex, columnindex).CellType.NToString() == "TextCellType")
                {
                    if (string.IsNullOrEmpty(spdOrder.Sheets[0].Cells.Get(rowindex, columnindex).CellType.NToString()))
                    {
                        celltype = (FarPoint.Win.Spread.CellType.TextCellType)spdOrder.Sheets[0].Columns.Get(columnindex).CellType;
                    }
                    else
                    {
                        celltype = (FarPoint.Win.Spread.CellType.TextCellType)spdOrder.Sheets[0].Cells.Get(rowindex, columnindex).CellType;
                    }
                    string sValue = spdOrder.GetCeLL(rowindex, columnindex);
                    Encoding sjis = Encoding.GetEncoding("shift-jis");

                    int iMax = celltype.MaxLength;

                    while (iMax < sjis.GetByteCount(sValue))
                    {
                        int curPoint = sValue.Length - 1;
                        if (curPoint < 0)
                        {
                            curPoint = 0;
                        }
                        sValue = sValue.Remove(curPoint, 1);
                    }
                    spdOrder.SetCeLL(rowindex, columnindex).Text = sValue;
                }
            }
            catch (SoapException soapex)
            {
                ExceptionInfo(soapex.ToString(), FaultCode.Server, this.Name);
            }
            catch (Exception ex)
            {
                ExceptionInfo(ex.ToString(), FaultCode.Client, this.Name);
            }
        }

当输入全角,超过最大可入力的字节,光标就会跳到第一个字符前面,怎么解决版主
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-10-20 17:06:40
地板
您 spdOrder.SetCeLL(rowindex, columnindex).Text = sValue; 后加上下面代码试试

                    var editor = fpSpread1.EditingControl as GeneralEditor;

                    if (editor != null)
                    {
                        editor.SelectionStart = sValue.Length;
                        editor.SelectionLength = 0;
                    }
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部