Doublick Text box not working

Chong

Well-known member
Joined
Apr 4, 2003
Messages
79
I have created the text box at run time and but when I create a sub routine for a DoubClick, this Sub never run even if I double click the text box to clear the value in it. Below is my code, please help you have any idea why.

Code:
Private WithEvents txtRank As System.Windows.Forms.TextBox

Private Sub txtBoxCreate()

Dim txtRank As New TextBox()

nlApplicant.SuspendLayout()
        With txtRank
            .Width = 20
            .Height = h
            .Location = New Point(x, y)
            .AutoSize = True
            .MaxLength = 2
            .BackColor = System.Drawing.Color.White
            .Visible = True
            .Anchor = AnchorStyles.Bottom
            .Show()
        End With
        pnlApplicant.Controls.Add(txtRank)
        pnlApplicant.ResumeLayout(True)
End Sub

Private Sub txtRank_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtRank.DoubleClick
        txtRank.Text = ""
End Sub

Many thanks in advance.

Chong
 
You need to Add a Handler for the text box, also, you dont need to declare it twice.
Code:
AddHandler txtRank.DoubleClick, AddressOf txtRank_DoubleClick
 
Back
Top