wpf如何在datagrid的PreviewTextInput事件中获取全文 [英] wpf how to get full text in PreviewTextInput event of datagrid

查看:321
本文介绍了wpf如何在datagrid的PreviewTextInput事件中获取全文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用数据网格。我想创建一个数字列,只允许一个点(。)运算符。我将验证代码放在PreviewTextInput事件中。如何在此事件中获取单元格中的全文。另外如何获取属性,如数据网格单元格的文本框的选择开始属性。请帮帮我..



谢谢和问候

Monish KM

Hi,
I am using data grid.I want to make a column numeric with allowing only a single dot(.) operator. I put validation code in PreviewTextInput event. How to get full text in a cell in this event.otherwise how to get property like select start property of text box for data grid cell. Please help me..

Thanks & Regards
Monish K.M

推荐答案

我不认为你可以从活动中得到它。你必须从TextBox本身获取它,所以你会写:



I dont think you can get it from the event. Youll have to get it from the TextBox itself so you would write:

String str = TextBox1.Text





或者在你的情况下,你必须从参数和转换中获取当前的datacell / sender对象这首先是文本框。看到这个链接:

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/e7959015-2170-41ad-bf64-0472fb94ad44/ [ ^ ]


String full = myTextBox.Text.Insert(myTextBox.CaretIndex,e.Text)
String full = myTextBox.Text.Insert(myTextBox.CaretIndex, e.Text)


这篇关于wpf如何在datagrid的PreviewTextInput事件中获取全文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆