Hello all,
I am trying to override OnPaint in a custom textbox
control (so I can drawstring a caption, etc.). In the
code below, I get the "painting the form" message as
expected, but not the "painting the control". It also
has no effect to explicitly call txtTest.Invalid ate or
txtTest.Refresh . Am I missing something simple here?
Any push in the right direction is appreciated.
BB
Public Class Form1
Inherits System.Windows. Forms.Form
#Region " Windows Form Designer generated code "
#End Region
Private Sub Form1_Load(ByVa l sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Load
Dim txtTest As New MyTextBox
Controls.Add(tx tTest)
End Sub
Protected Overrides Sub onpaint(ByVal e As
PaintEventArgs)
MessageBox.Show ("Painting the form...")
End Sub
End Class
Public Class MyTextBox
Inherits TextBox
Protected Overrides Sub onpaint(ByVal e As
PaintEventArgs)
MessageBox.Show ("Painting the textbox...")
End Sub
End Class
I am trying to override OnPaint in a custom textbox
control (so I can drawstring a caption, etc.). In the
code below, I get the "painting the form" message as
expected, but not the "painting the control". It also
has no effect to explicitly call txtTest.Invalid ate or
txtTest.Refresh . Am I missing something simple here?
Any push in the right direction is appreciated.
BB
Public Class Form1
Inherits System.Windows. Forms.Form
#Region " Windows Form Designer generated code "
#End Region
Private Sub Form1_Load(ByVa l sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Load
Dim txtTest As New MyTextBox
Controls.Add(tx tTest)
End Sub
Protected Overrides Sub onpaint(ByVal e As
PaintEventArgs)
MessageBox.Show ("Painting the form...")
End Sub
End Class
Public Class MyTextBox
Inherits TextBox
Protected Overrides Sub onpaint(ByVal e As
PaintEventArgs)
MessageBox.Show ("Painting the textbox...")
End Sub
End Class
Comment