如何在不触发TextChanged事件的情况下更改文本框中的文本? [英] How to change the text in textbox without letting the TextChanged Event to fire?

查看:56
本文介绍了如何在不触发TextChanged事件的情况下更改文本框中的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dear all

我制作了一个数字文本框,当用户输入金额时,当文本框失去焦点时,它将自动添加逗号.一切正常,除非我发现我有问题,并且经过长时间检查,我意识到这是由于添加 逗号.

I made a numeric textbox that when user insert the amount it will automatically add comma when the textbox lose it's focus. Everything works well except I figure out that I have a problem and after long checking I realize it is coming from adding comma.

在使用此数字文本框的代码中,我主要使用事件TextChanged.现在的问题是,当系统添加逗号时,它甚至会再次触发,并且将更改我的代码中的所有内容.现在我的问题是,如何停止触发TextChange Event 当我要添加逗号时.

In the codes that I use this numeric textbox I mostly use the event TextChanged. Now the problem is that when system add comma this even will fire again and it will change everything in my code. Now my question is that how can I stop TextChange Event from firing when I want to add comma.

我只需要关闭TextChange Event添加逗号,然后再次将其打开即可.

Simply I just need to turn off TextChange Event add comma then turn it on again.

有可能吗?

我正在使用VB.Net和WPF进行编码

I am coding using VB.Net and WPF

非常感谢

一切皆有可能

推荐答案

萨满,

 如果您不想使用任何事件,请使用Bindings使它们起作用.如下

 If you dont want to use any events use Bindings for the same to work. as follows

 <TextBox Text="{Binding FirstName}"/>


这篇关于如何在不触发TextChanged事件的情况下更改文本框中的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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