回复 1楼menghuanyunxia的帖子
测试代码如下:
- private void Form1_Load(object sender, EventArgs e)
- {
- FarPoint.Win.Spread.CellType.TextCellType t = new FarPoint.Win.Spread.CellType.TextCellType();
- FarPoint.Win.Spread.InputMap ancestorOfFocusedMap = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused);
- FarPoint.Win.Spread.ActionMap am = fpSpread1.GetActionMap();
- am.Put("AltEnter", new myAction());
- ancestorOfFocusedMap.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextRow );
- ancestorOfFocusedMap.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.Alt), "AltEnter");
- fpSpread1.SetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused, ancestorOfFocusedMap);
- t.Multiline = true;
- fpSpread1.Sheets[0].Cells[1, 1].CellType = t;
- fpSpread1.Sheets[0].Rows[1].Height = 60;
- fpSpread1.Sheets[0].Columns[1].Width = 140;
- }
-
- private void fpSpread1_EditModeOn(object sender, EventArgs e)
- {
- FarPoint.Win.Spread.CellType.GeneralEditor myText = (FarPoint.Win.Spread.CellType.GeneralEditor)fpSpread1.EditingControl;
- myText.AcceptsReturn = false;
- }
- }
- public class myAction : FarPoint.Win.Spread.Action
- {
- public override void PerformAction(object sender)
- {
- FarPoint.Win.Spread.SpreadView ss = (FarPoint.Win.Spread.SpreadView)sender;
- FarPoint.Win.Spread.CellType.GeneralEditor editor = (FarPoint.Win.Spread.CellType.GeneralEditor)ss.EditingControl;
- string text = editor.Text;
- text += "\n";
- ss.Sheets[0].SetValue(ss.Sheets[0].ActiveRowIndex, ss.Sheets[0].ActiveColumnIndex, text);
- ss.EditMode = true;
- editor = (FarPoint.Win.Spread.CellType.GeneralEditor)ss.EditingControl;
- editor.SelectionStart = editor.Text.Length;
- }
- }
- }
复制代码
为了给你提供更优质的服务,请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢 |