I have a custom textbox class that is set public scope. I created it because I needed to override the WndProc sub to handle paste messages sent from this control. The problem I'm having is that when the form is compiled, I get no error messages but the textbox doesn't show on the form. I've posted my code below, and would appreciate any observations on what I missed. I'm sure it's something simple...
Code:
Public Class optyTextBox
Inherits System.Windows.Forms.TextBox
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Const WM_PASTE As Int32 = &H302
Select Case m.Msg
Case WM_PASTE ' The clipboard contents were pasted...
'Code to handle paste event.
End Select
End Sub
End Class
Shared WithEvents txtZip As optyTextBox
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
txtZip = New optyTextBox
txtZip.Name = "txtZip"
txtZip.Font = New System.Drawing.Font("Tahoma", 6.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
txtZip.Location = New System.Drawing.Point(142, 160)
txtZip.Margin = New System.Windows.Forms.Padding(2, 3, 2, 3)
txtZip.Size = New System.Drawing.Size(59, 18)
txtZip.TabIndex = 28
txtZip.Visible = True ' Shouldn't this work?
Me.Controls.Add(txtZip)
txtZip.Show() ' I tried using this line to see if it forced the control to
'be visible but no dice...
End Sub
Last edited: