找回密码
 立即注册

QQ登录

只需一步,快速开始

Kissmint

银牌会员

18

主题

36

帖子

2730

积分

银牌会员

积分
2730

活字格认证

Kissmint
银牌会员   /  发表于:2015-5-22 14:34  /   查看:5270  /  回复:2
需求:
现在有个multiRow,里面有普通的Cell,还有个Button Cell。
对于普通Cell,按下Enter,去下一个Cell,
对于Button Cell,按下Enter,想要响应其Click事件。

能够实现吗?

已经解决,结贴

2 个回复

倒序浏览
Carl
版主   /  发表于:2015-5-22 16:13:00
沙发
可以用自定义Action来实现。

  1.         private class MyCustomAction : GrapeCity.Win.MultiRow.IAction
  2.         {
  3.             public string DisplayName
  4.             {
  5.                 get { return "MyCustomAction"; }
  6.             }

  7.             public bool CanExecute(GcMultiRow target)
  8.             {
  9.                 return target.CurrentCell != null;
  10.             }

  11.             public void Execute(GcMultiRow target)
  12.             {
  13.                 if (target.CurrentCell is ButtonCell)
  14.                 {
  15.                     // Do your button click logic here.
  16.                     Console.WriteLine("Current Button is clicked.");
  17.                 }
  18.                 else
  19.                 {
  20.                     SelectionActions.MoveToNextRow.Execute(target);
  21.                 }
  22.             }
  23.         }
复制代码

把这个Action注册给MultiRow:

  1.             this.gcMultiRow1.ShortcutKeyManager.Register(new MyCustomAction(), Keys.Enter);
复制代码


默认情况下,按Enter键是注册到进入/退出编辑状态的。如果把Enter键注册给移动到下一行,建议把Shift+Enter注册给移动到上一行。其他关于Action的内容,安装包里应该有demo吧。

评分

参与人数 1金币 +500 收起 理由
Alice + 500 感谢提供详细的代码。

查看全部评分

愿 Engine 归于沉寂,Timer 停止运动,Message Queue 不再流淌,Data Source 为我掌握
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2015-5-22 16:18:00
板凳
回复 1楼Kissmint的帖子

感谢你的反馈。
也谢谢@Carl 的分享。
此问题关闭,如果有新问题请开新帖。
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部