Advertisement
CorrM

Transparent TextBox

Oct 28th, 2017
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.05 KB | None | 0 0
  1. Public Class CorrMTextBox
  2.     Inherits RichTextBox
  3.  
  4.     Public Sub New()
  5.         Me.BorderStyle = 0
  6.         Me.ScrollBars = RichTextBoxScrollBars.None
  7.         Me.Size = New Size(100, 20)
  8.         Me.WordWrap = False
  9.         Me.SetStyle(ControlStyles.Opaque, True)
  10.         Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, False)
  11.     End Sub
  12.  
  13.     Sub ForceRefresh(sender As Object, e As EventArgs) Handles Me.TextChanged
  14.         Me.UpdateStyles()
  15.     End Sub
  16.  
  17.     Sub CorrMTextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
  18.         If e.KeyCode = Keys.Enter Then
  19.             e.Handled = True
  20.         End If
  21.     End Sub
  22.  
  23.     Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
  24.         Get
  25.             Dim cp As CreateParams = MyBase.CreateParams
  26.             cp.ExStyle = cp.ExStyle Or &H20 ''#WS_EX_TRANSPARENT
  27.             Return cp
  28.         End Get
  29.     End Property
  30.  
  31.     Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  32.     End Sub
  33.  
  34. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement