R
Rob
Question : I want to create a read only TextBox that does not
respond to any input from the keyboard, therefore I came up
with the following derived class :
Option Strict On
Imports System.Windows.Forms.TextBox
Public Class DerivedTextBox
Inherits TextBox
Protected Overridable Sub KeyEventHandler( _
ByVal sender As Object, _
ByVal e As KeyEventHandler)
End Sub
End Class
I then place this TextBox on my Form1 using the following :
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
Me.TextBox1.Show()
'
'TextBox1
'
Me.TextBox1.AutoSize = False
Me.TextBox1.Location = New System.Drawing.Point(8, 8)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.ReadOnly = True
Me.TextBox1.Size = New System.Drawing.Size(230, 150)
Me.TextBox1.TabIndex = 1
Me.TextBox1.TabStop = False
Me.TextBox1.Text = ""
Me.TextBox1.Visible = True
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Friend WithEvents TextBox1 As DerivedTextBox
However the TextBox remains invisible. How can I get
TextBox1 to appear on Form1 ?
respond to any input from the keyboard, therefore I came up
with the following derived class :
Option Strict On
Imports System.Windows.Forms.TextBox
Public Class DerivedTextBox
Inherits TextBox
Protected Overridable Sub KeyEventHandler( _
ByVal sender As Object, _
ByVal e As KeyEventHandler)
End Sub
End Class
I then place this TextBox on my Form1 using the following :
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
Me.TextBox1.Show()
'
'TextBox1
'
Me.TextBox1.AutoSize = False
Me.TextBox1.Location = New System.Drawing.Point(8, 8)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.ReadOnly = True
Me.TextBox1.Size = New System.Drawing.Size(230, 150)
Me.TextBox1.TabIndex = 1
Me.TextBox1.TabStop = False
Me.TextBox1.Text = ""
Me.TextBox1.Visible = True
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Friend WithEvents TextBox1 As DerivedTextBox
However the TextBox remains invisible. How can I get
TextBox1 to appear on Form1 ?