|
-
Apr 16th, 2003, 03:29 PM
#1
Thread Starter
Addicted Member
Doubclick Text Box not working
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.
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
Thanks!
Chong
-
Apr 16th, 2003, 04:03 PM
#2
Doubleclick on a textbox worked fine for me. Do you also have something handling the Click event? If so then the SingleClick or Click event will prevent the DoubleClick from happening.
-
Apr 16th, 2003, 04:07 PM
#3
Actually taking a second peek at your code, you don't ever assign the txtRank that is local to the txtBoxCreate method to the form level txtRank that is set to handle events. In fact I'm not sure it you can assign one to the other like that, but if you can it would be like this in the txtBoxCreate method:
The better way would be to use the AddHandler method to add the event handling:
VB Code:
AddHandler(txtRank.Click,AddressOf txtRank_DoubleClick)
-
Apr 16th, 2003, 05:44 PM
#4
Sleep mode
I posted an example in this thread (maybe it gives your an idea how handlers work ) . Your code seems a bit weird to me . Why did you declare txtRank inside the sub ?
http://www.vbforums.com/showthread.p...ighlight=Timer
-
Apr 17th, 2003, 07:56 AM
#5
Thread Starter
Addicted Member
Thank you very much! I'm greatly appreciated! I'm pretty it has to do with the Addhandler. I'll give that a try.
Chong
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|