如何在文本框中检查文本数据是否被修改 [英] how to check text data is modified or not in text box

查看:108
本文介绍了如何在文本框中检查文本数据是否被修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框.我正在文本框中写一些文本,并将此文本另存为word文件.
如果我在文本框中写了一些文本但没有保存该文本,然后在那时关闭了应用程序,那么我会收到一条消息:数据尚未保存,您要关闭该应用程序吗?"
我该怎么办?

在此先感谢...

HI i have a one text box. i am writing some text in text box and save this text as a word file.
if i write some text in a text box and doesn''t save the text and then close the application at that time i want a message "The data has not been saved are you want to close the application"
how could i do this ?

Thanks in Advance ...

推荐答案

这很简单,只有逻辑

1.
如果他关闭应用程序,则计算文本长度,如果长度> 0
提示相应的消息.

如果您想知道用户是否在文本框中进行了修改
看吧

最初将状态变量保持为零


It is very simple it is only logic

1.
Count text length when he close the application, if the length>0
prompt appropriate message.

If you want to know the user modified in the textbox or not
Look it

Maintain status variable initially Zero

In the
TextChanged 


事件设置状态= 1,并提示您的消息

谢谢
SP


event set status=1 and prompt your message

Thanks
SP


将成员变量声明为
Declare a member variable as
flagTextChanged=false;



TextBox的OnTextChanged



OnTextChanged of TextBox

flagTextChanged=true;



OnFormClose



OnFormClose

if(flagTextChanged)
MessageBox.Show("Not Saved Message");



祝你好运



Best of Luck




您可以在文本框的离开事件中对其进行检查.

如果您不知道文本框的离开事件,请阅读

[^ ]

离开文本框时,文本框的离开事件会触发.
Hi,

you can check it at the leave event of the textbox.

if you did not know leave event of textbox then read

[^]

Leave event of textbox is fire when you leave textbox.


这篇关于如何在文本框中检查文本数据是否被修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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