home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic .NET - Read Less - Learn More / Visual_Basic.NET_Read_Less_Learn_More_Richard_Bowman_Visual_2002.iso / Resources / Code / Ch12-HandleDefaultProperties / UserControl1.vb < prev   
Text File  |  2001-09-04  |  2KB  |  71 lines

  1. Public Class UserControl1
  2.     Inherits System.Windows.Forms.UserControl
  3.  
  4. #Region " Windows Form Designer generated code "
  5.  
  6.     Public Sub New()
  7.         MyBase.New()
  8.  
  9.         'This call is required by the Windows Form Designer.
  10.         InitializeComponent()
  11.  
  12.         'Add any initialization after the InitializeComponent() call
  13.  
  14.     End Sub
  15.  
  16.     'UserControl1 overrides dispose to clean up the component list.
  17.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  18.         If disposing Then
  19.             If Not (components Is Nothing) Then
  20.                 components.Dispose()
  21.             End If
  22.         End If
  23.         MyBase.Dispose(disposing)
  24.     End Sub
  25.  
  26.     'Required by the Windows Form Designer
  27.     Private components As System.ComponentModel.Container
  28.  
  29.     'NOTE: The following procedure is required by the Windows Form Designer
  30.     'It can be modified using the Windows Form Designer.  
  31.     'Do not modify it using the code editor.
  32.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  33.         '
  34.         'UserControl1
  35.         '
  36.         Me.Name = "UserControl1"
  37.         Me.Size = New System.Drawing.Size(192, 120)
  38.  
  39.     End Sub
  40.  
  41. #End Region
  42.  
  43.     Private myBackColor As Color
  44.  
  45.     Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  46.  
  47.     End Sub
  48.  
  49.     Private Sub UserControl1_EnabledChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.EnabledChanged
  50.         ' do not allow this control to be disabled
  51.         If Me.Enabled = False Then
  52.             Me.Enabled = True
  53.         End If
  54.     End Sub
  55.  
  56.     Public Overrides Property BackColor() As System.Drawing.Color
  57.         Get
  58.             Return myBackColor
  59.         End Get
  60.         Set(ByVal Value As System.Drawing.Color)
  61.             myBackColor = Value
  62.             Invalidate()
  63.         End Set
  64.     End Property
  65.  
  66.     Private Sub UserControl1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
  67.         Dim b As New Drawing2D.LinearGradientBrush(e.ClipRectangle, Color.Black, myBackColor, Drawing.Drawing2D.LinearGradientMode.Vertical)
  68.         e.Graphics.FillRectangle(b, e.ClipRectangle)
  69.     End Sub
  70. End Class
  71.