找回密码
 立即注册

QQ登录

只需一步,快速开始

menghuanyunxia

高级会员

111

主题

396

帖子

1075

积分

高级会员

积分
1075

活字格认证微信认证勋章元老葡萄

menghuanyunxia
高级会员   /  发表于:2015-1-5 10:15  /   查看:4428  /  回复:1
farpoint7如何实现编辑的单元格内文字换行,excel的单元格内换行按键为Alt+Enter

1 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2015-1-5 11:53:00
沙发
回复 1楼menghuanyunxia的帖子

测试代码如下:

  1. private void Form1_Load(object sender, EventArgs e)
  2. {
  3.       FarPoint.Win.Spread.CellType.TextCellType t = new FarPoint.Win.Spread.CellType.TextCellType();
  4.       FarPoint.Win.Spread.InputMap ancestorOfFocusedMap = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused);
  5.       FarPoint.Win.Spread.ActionMap am = fpSpread1.GetActionMap();
  6.       am.Put("AltEnter", new myAction());
  7.       ancestorOfFocusedMap.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextRow );
  8.       ancestorOfFocusedMap.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.Alt), "AltEnter");
  9.       fpSpread1.SetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused, ancestorOfFocusedMap);
  10.       t.Multiline = true;
  11.       fpSpread1.Sheets[0].Cells[1, 1].CellType = t;
  12.       fpSpread1.Sheets[0].Rows[1].Height = 60;
  13.       fpSpread1.Sheets[0].Columns[1].Width = 140;
  14.     }

  15.     private void fpSpread1_EditModeOn(object sender, EventArgs e)
  16.     {
  17.       FarPoint.Win.Spread.CellType.GeneralEditor myText = (FarPoint.Win.Spread.CellType.GeneralEditor)fpSpread1.EditingControl;
  18.       myText.AcceptsReturn = false;
  19.     }
  20.   }
  21.   public class myAction : FarPoint.Win.Spread.Action
  22.   {
  23.     public override void PerformAction(object sender)
  24.     {
  25.       FarPoint.Win.Spread.SpreadView ss = (FarPoint.Win.Spread.SpreadView)sender;
  26.       FarPoint.Win.Spread.CellType.GeneralEditor editor = (FarPoint.Win.Spread.CellType.GeneralEditor)ss.EditingControl;
  27.       string text = editor.Text;
  28.       text += "\n";
  29.       ss.Sheets[0].SetValue(ss.Sheets[0].ActiveRowIndex, ss.Sheets[0].ActiveColumnIndex, text);
  30.       ss.EditMode = true;
  31.       editor = (FarPoint.Win.Spread.CellType.GeneralEditor)ss.EditingControl;
  32.       editor.SelectionStart = editor.Text.Length;
  33.     }
  34.   }
  35. }

复制代码


为了给你提供更优质的服务,请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部