I for the life of me, can not figure out how to get the text to repaint over my background. When the paint event fires, all text disappears.
VB.Net Code:
Imports System.ComponentModel Public Class UserControl1 Inherits TextBox Private pic As Image Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. SetStyle(ControlStyles.UserPaint, True) End Sub Protected Overrides Sub OnKeyPress(ByVal e As KeyPressEventArgs) If Char.IsNumber(e.KeyChar) = False Then e.Handled = True End If End Sub Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaint(e) e.Graphics.DrawImage(pic, 0, 0, 32, 32) End Sub <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible), _ Description("Select a icon for the textbox."), _ Browsable(True)> _ Public Property Picture() As Image Get Return pic End Get Set(ByVal value As Image) pic = value Me.Invalidate() End Set End Property End Class
Any help is appreciated.




Reply With Quote