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;

}

}

相关推荐
玖笙&2 天前
✨WPF编程基础【2.1】布局原则
c++·wpf·visual studio
玖笙&2 天前
✨WPF编程基础【2.2】:布局面板实战
c++·wpf·visual studio
SEO-狼术2 天前
.NET WPF 数据编辑器集合提供列表框控件
.net·wpf
FuckPatience6 天前
WPF 具有跨线程功能的UI元素
wpf
诗仙&李白7 天前
HEFrame.WpfUI :一个现代化的 开源 WPF UI库
ui·开源·wpf
He BianGu7 天前
【笔记】在WPF中Binding里的详细功能介绍
笔记·wpf
He BianGu7 天前
【笔记】在WPF中 BulletDecorator 的功能、使用方式并对比 HeaderedContentControl 与常见 Panel 布局的区别
笔记·wpf
123梦野8 天前
WPF——效果和可视化对象
wpf
He BianGu8 天前
【笔记】在WPF中Decorator是什么以及何时优先考虑 Decorator 派生类
笔记·wpf
时光追逐者8 天前
一款专门为 WPF 打造的开源 Office 风格用户界面控件库
ui·开源·c#·.net·wpf