提示保存文本框更改 [英] prompt save on textbox change

查看:83
本文介绍了提示保存文本框更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个代码,提示保存文本框更改.我使用一个功能

i have a code that prompts save on textbox change. i use a function

Dim loaded As Boolean = False
    Dim txtChanged As Boolean = False





Private Sub Text_Changed(ByVal sender As Object, ByVal e As System.EventArgs)

        If loaded Then
            txtChanged = True
        End If
    End Sub




然后加载





then on load


For Each cntrl As Control In Me.GroupBox1.Controls
            If TypeOf (cntrl) Is TextBox Then
                AddHandler cntrl.TextChanged, AddressOf Text_Changed
            End If



并在关闭时检查标志.
这有效..但是一旦我退格或清除了特定的文本框,它仍然会以textchange的形式出现.



and on closing i check on the flag.
this works.. but once i backspace or clear a particular textbox, it still presents as a textchange. is there a turnaround for this?

推荐答案

TextChanged事件针对文本框中的每个文本更改(包括退格和清除文本)触发.如果您希望处理特定的更改,则必须相应地编写代码.例如,您可以处理KeyPress事件,如果按下Backspace,则可以在TextBox.Tag属性中设置一个标志,然后相应地处理这种情况.
The TextChanged event fires for every change of text in the textbox (this includes backspace and clearing the text). If you wish to handle specific changes, you have to write code accordingly. For example, you could handle the KeyPress event and if Backspace is pressed, you can set a flag in the TextBox.Tag property and then handle the situation accordingly.


这篇关于提示保存文本框更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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