WPF的C1FlexGrid的单元格回车换行输入

重写C1FlexGrid的按键事件

PreviewKeyDown="flex_PreviewKeyUp"

定义按键方法

private void flex_PreviewKeyUp(object sender, KeyEventArgs e)

{

if (e.Key == Key.Enter)

{

// 获取当前编辑的单元格

var cell = CfgReviewItem.Selection;

if (cell.Column >= 0 && cell.Row >= 0)

{

// 获取当前单元格的编辑器(C1MaskedTextBox)

var editor = e.OriginalSource as C1MaskedTextBox;

if (editor != null)

{

// 插入换行符

int caretIndex = editor.CaretIndex;

editor.Text = editor.Text.Insert(caretIndex, Environment.NewLine);

editor.CaretIndex = caretIndex + Environment.NewLine.Length;

}

}

e.Handled = true;

}

}

相关推荐
心平气和量大福大43 分钟前
C#-WPF-控件-TextBox 数据绑定
开发语言·c#·wpf
listening7779 小时前
HarmonyOS 6.1 全场景协同实战:从“单机”到“超级终端”的分布式重构
wpf
心平气和量大福大1 天前
C#-WPF-布局-Grid
c#·wpf·visual studio
心平气和量大福大2 天前
C#-WPF-Window主窗体
开发语言·c#·wpf
FuckPatience2 天前
Telerik UI for WPF 值不能为null。参数名:key
ui·wpf
lindexi2 天前
WPF 笔迹延迟优化从硬件到软件的全链路分析
wpf
weixin_727535623 天前
双Token认证体系深度拆解:Spring Security + JWT + Redis
redis·spring·wpf
liuxiaowei33 天前
Winform+WPF双框架实战:喷涂工艺SCADA上位机从0到1搭建(附采集监控源码+车间踩坑实录)
大数据·hadoop·wpf
贺国亚4 天前
模型训练-分布式与GPU调度
分布式·wpf
不羁的木木5 天前
HarmonyOS技术精讲-Connectivity Kit:实战——多屏协同与文件快传应用
华为·wpf·harmonyos