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);
}
}
当输入全角,超过最大可入力的字节,光标就会跳到第一个字符前面,怎么解决版主 |