Click here to Skip to main content
15,891,607 members
Articles / Multimedia / GDI+

Custom Button Control with Gradient Colors and Extra Image (VB.NET)

Rate me:
Please Sign up or sign in to vote.
4.91/5 (131 votes)
19 Mar 2015CPOL7 min read 817.6K   46.9K   232  
This is a simple to use custom button control, but with a lot of visual design options.
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmDialog
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim DesignerRectTracker5 As CButtonLib.DesignerRectTracker = New CButtonLib.DesignerRectTracker
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmDialog))
        Dim CBlendItems3 As CButtonLib.cBlendItems = New CButtonLib.cBlendItems
        Dim DesignerRectTracker6 As CButtonLib.DesignerRectTracker = New CButtonLib.DesignerRectTracker
        Dim DesignerRectTracker1 As CButtonLib.DesignerRectTracker = New CButtonLib.DesignerRectTracker
        Dim CBlendItems1 As CButtonLib.cBlendItems = New CButtonLib.cBlendItems
        Dim DesignerRectTracker2 As CButtonLib.DesignerRectTracker = New CButtonLib.DesignerRectTracker
        Me.CButton_Cancel = New CButtonLib.CButton
        Me.CButton_OK = New CButtonLib.CButton
        Me.SuspendLayout()
        '
        'CButton_Cancel
        '
        DesignerRectTracker5.IsActive = False
        DesignerRectTracker5.TrackerRectangle = CType(resources.GetObject("DesignerRectTracker5.TrackerRectangle"), System.Drawing.RectangleF)
        Me.CButton_Cancel.CenterPtTracker = DesignerRectTracker5
        CBlendItems3.iColor = New System.Drawing.Color() {System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(192, Byte), Integer)), System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer)), System.Drawing.Color.FromArgb(CType(CType(128, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer))}
        CBlendItems3.iPoint = New Single() {0.0!, 0.4982207!, 1.0!}
        Me.CButton_Cancel.ColorFillBlend = CBlendItems3
        Me.CButton_Cancel.ColorFillSolid = System.Drawing.SystemColors.Control
        Me.CButton_Cancel.Corners.All = CType(6, Int32)
        Me.CButton_Cancel.Corners.LowerLeft = CType(6, Int32)
        Me.CButton_Cancel.Corners.LowerRight = CType(6, Int32)
        Me.CButton_Cancel.Corners.UpperLeft = CType(6, Int32)
        Me.CButton_Cancel.Corners.UpperRight = CType(6, Int32)
        Me.CButton_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.CButton_Cancel.FocalPoints.CenterPtX = 0.5!
        Me.CButton_Cancel.FocalPoints.CenterPtY = 0.5!
        Me.CButton_Cancel.FocalPoints.FocusPtX = 0.0!
        Me.CButton_Cancel.FocalPoints.FocusPtY = 0.0!
        DesignerRectTracker6.IsActive = False
        DesignerRectTracker6.TrackerRectangle = CType(resources.GetObject("DesignerRectTracker6.TrackerRectangle"), System.Drawing.RectangleF)
        Me.CButton_Cancel.FocusPtTracker = DesignerRectTracker6
        Me.CButton_Cancel.Font = New System.Drawing.Font("Arial", 10.0!, System.Drawing.FontStyle.Bold)
        Me.CButton_Cancel.ForeColor = System.Drawing.Color.White
        Me.CButton_Cancel.Image = Nothing
        Me.CButton_Cancel.ImageAlign = System.Drawing.ContentAlignment.MiddleCenter
        Me.CButton_Cancel.ImageIndex = 0
        Me.CButton_Cancel.ImageSize = New System.Drawing.Size(16, 16)
        Me.CButton_Cancel.Location = New System.Drawing.Point(168, 33)
        Me.CButton_Cancel.Name = "CButton_Cancel"
        Me.CButton_Cancel.SideImage = Nothing
        Me.CButton_Cancel.SideImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.CButton_Cancel.SideImageSize = New System.Drawing.Size(48, 48)
        Me.CButton_Cancel.Size = New System.Drawing.Size(90, 25)
        Me.CButton_Cancel.TabIndex = 0
        Me.CButton_Cancel.Text = "Cancel"
        Me.CButton_Cancel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        Me.CButton_Cancel.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay
        Me.CButton_Cancel.TextMargin = New System.Windows.Forms.Padding(2)
        Me.CButton_Cancel.TextSmoothingMode = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit
        Me.CButton_Cancel.UseMnemonic = True
        '
        'CButton_OK
        '
        DesignerRectTracker1.IsActive = False
        DesignerRectTracker1.TrackerRectangle = CType(resources.GetObject("DesignerRectTracker1.TrackerRectangle"), System.Drawing.RectangleF)
        Me.CButton_OK.CenterPtTracker = DesignerRectTracker1
        CBlendItems1.iColor = New System.Drawing.Color() {System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer)), System.Drawing.Color.FromArgb(CType(CType(50, Byte), Integer), CType(CType(205, Byte), Integer), CType(CType(50, Byte), Integer)), System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(100, Byte), Integer), CType(CType(0, Byte), Integer))}
        CBlendItems1.iPoint = New Single() {0.0!, 0.5!, 1.0!}
        Me.CButton_OK.ColorFillBlend = CBlendItems1
        Me.CButton_OK.ColorFillSolid = System.Drawing.SystemColors.Control
        Me.CButton_OK.Corners.All = CType(6, Int32)
        Me.CButton_OK.Corners.LowerLeft = CType(6, Int32)
        Me.CButton_OK.Corners.LowerRight = CType(6, Int32)
        Me.CButton_OK.Corners.UpperLeft = CType(6, Int32)
        Me.CButton_OK.Corners.UpperRight = CType(6, Int32)
        Me.CButton_OK.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.CButton_OK.FocalPoints.CenterPtX = 0.5!
        Me.CButton_OK.FocalPoints.CenterPtY = 0.5!
        Me.CButton_OK.FocalPoints.FocusPtX = 0.0!
        Me.CButton_OK.FocalPoints.FocusPtY = 0.0!
        DesignerRectTracker2.IsActive = False
        DesignerRectTracker2.TrackerRectangle = CType(resources.GetObject("DesignerRectTracker2.TrackerRectangle"), System.Drawing.RectangleF)
        Me.CButton_OK.FocusPtTracker = DesignerRectTracker2
        Me.CButton_OK.Font = New System.Drawing.Font("Arial", 10.0!, System.Drawing.FontStyle.Bold)
        Me.CButton_OK.ForeColor = System.Drawing.Color.White
        Me.CButton_OK.Image = Nothing
        Me.CButton_OK.ImageAlign = System.Drawing.ContentAlignment.MiddleCenter
        Me.CButton_OK.ImageIndex = 0
        Me.CButton_OK.ImageSize = New System.Drawing.Size(16, 16)
        Me.CButton_OK.Location = New System.Drawing.Point(24, 33)
        Me.CButton_OK.Name = "CButton_OK"
        Me.CButton_OK.SideImage = Nothing
        Me.CButton_OK.SideImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.CButton_OK.SideImageSize = New System.Drawing.Size(48, 48)
        Me.CButton_OK.Size = New System.Drawing.Size(90, 25)
        Me.CButton_OK.TabIndex = 0
        Me.CButton_OK.Text = "OK"
        Me.CButton_OK.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        Me.CButton_OK.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay
        Me.CButton_OK.TextMargin = New System.Windows.Forms.Padding(2)
        Me.CButton_OK.TextSmoothingMode = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit
        Me.CButton_OK.UseMnemonic = True
        '
        'Form2
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(286, 92)
        Me.Controls.Add(Me.CButton_Cancel)
        Me.Controls.Add(Me.CButton_OK)
        Me.Name = "Form2"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
        Me.Text = "Test Dialog"
        Me.ResumeLayout(False)

    End Sub
    Friend WithEvents CButton_OK As CButtonLib.CButton
    Friend WithEvents CButton_Cancel As CButtonLib.CButton
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
I first got hooked on programing with the TI994A. After it finally lost all support I reluctantly moved to the Apple IIe. Thank You BeagleBros for getting me through. I wrote programs for my Scuba buisness during this time. Currently I am a Database manager and software developer. I started with VBA and VB6 and now having fun with VB.NET/WPF/C#...

Comments and Discussions