【问题标题】:custom ASP.NET TextBox on textchanged eventtextchanged 事件上的自定义 ASP.NET TextBox
【发布时间】:2010-03-10 12:10:32
【问题描述】:

我想让 TextBox 控制 TextChanged 事件仅在 TextBox 中有多个字符时触发。

谢谢。

【问题讨论】:

    标签: asp.net vb.net asp.net-ajax


    【解决方案1】:
    Public Class ZTextBox
    Inherits System.Windows.Forms.TextBox
    Public Event ZTextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    
    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        MyBase.OnPaint(e)
    
        'Add your custom paint code here
    End Sub
    
    Private Sub ZTextBox_TextChanged1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.TextChanged
        If Me.Text.Length > 3 Then
            RaiseEvent ZTextChanged(sender, e)
        End If
    End Sub End Class
    

    您可以在表单中使用以下内容

        Private Sub ZTextBox1_ZTextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ZTextBox1.ZTextChanged
        MsgBox(1)
    End Sub
    

    【讨论】:

      【解决方案2】:

      我认为您需要一个自定义控件,该控件通过自定义事件继承文本框控件,检查内部事件,并在您认为合适时触发自定义事件。

      【讨论】:

        猜你喜欢
        • 2011-02-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多