Color Dialog: Changing the background and text colors of a form : Color « 2D « VB.Net

VB.Net
1. 2D
2. Application
3. Class
4. Data Structure
5. Database ADO.net
6. Development
7. Event
8. File Directory
9. Generics
10. GUI
11. Language Basics
12. Network Remote
13. Thread
14. Windows System
15. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net Tutorial
VB.Net » 2D » ColorScreenshots 
Color Dialog: Changing the background and text colors of a form
Color Dialog: Changing the background and text colors of a form

Imports System
Imports System.Drawing
Imports System.Windows.Forms

Public Class MainClass

   Shared Sub Main()
        Dim myform As Form = New FrmColorDialogTest()
        Application.Run(myform)
   End Sub ' Main

End Class


Public Class FrmColorDialogTest
   Inherits System.Windows.Forms.Form

   Friend WithEvents cmdBackgroundButton As Button
   Friend WithEvents cmdTextButton As Button

#Region " Windows Form Designer generated code "

   Public Sub New()
      MyBase.New()

      'This call is required by the Windows Form Designer.
      InitializeComponent()

      'Add any initialization after the InitializeComponent() call

   End Sub

   'Form overrides dispose to clean up the component list.
   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
      If disposing Then
         If Not (components Is NothingThen
            components.Dispose()
         End If
      End If
      MyBase.Dispose(disposing)
   End Sub

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

   '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.cmdBackgroundButton = New System.Windows.Forms.Button()
      Me.cmdTextButton = New System.Windows.Forms.Button()
      Me.SuspendLayout()
      '
      'cmdBackgroundButton
      '
      Me.cmdBackgroundButton.Location = New System.Drawing.Point(1616)
      Me.cmdBackgroundButton.Name = "cmdBackgroundButton"
      Me.cmdBackgroundButton.Size = New System.Drawing.Size(16024)
      Me.cmdBackgroundButton.TabIndex = 0
      Me.cmdBackgroundButton.Text = "Change Background Color"
      '
      'cmdTextButton
      '
      Me.cmdTextButton.Location = New System.Drawing.Point(1656)
      Me.cmdTextButton.Name = "cmdTextButton"
      Me.cmdTextButton.Size = New System.Drawing.Size(16024)
      Me.cmdTextButton.TabIndex = 1
      Me.cmdTextButton.Text = "Change Text Color"
      '
      'FrmColorDialogTest
      '
      Me.AutoScaleBaseSize = New System.Drawing.Size(513)
      Me.ClientSize = New System.Drawing.Size(19293)
      Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdTextButton, Me.cmdBackgroundButton})
      Me.Name = "FrmColorDialogTest"
      Me.Text = "Using Color Dialogs"
      Me.ResumeLayout(False)

   End Sub

#End Region

   Private Sub cmdTextButton_Click(ByVal sender As System.Object, _
      ByVal e As System.EventArgsHandles cmdTextButton.Click

      Dim colorBox As ColorDialog = New ColorDialog()
      Dim result As DialogResult

      result = colorBox.ShowDialog()
      If result = DialogResult.Cancel Then
         Return
      End If

      cmdBackgroundButton.ForeColor = colorBox.Color
      cmdTextButton.ForeColor = colorBox.Color
   End Sub 

   Private Sub cmdBackgroundButton_Click_
      ByVal sender As System.Object, _
      ByVal e As System.EventArgs_
      Handles cmdBackgroundButton.Click

      Dim colorBox As ColorDialog = New ColorDialog()
      Dim result As DialogResult

      colorBox.FullOpen = True
      result = colorBox.ShowDialog()

      If result = DialogResult.Cancel Then
         Return
      End If

      Me.BackColor = colorBox.Color
   End Sub  

End Class 
           
       
Related examples in the same category
1. Get all Known color and calcuate its Brightness and SaturationGet all Known color and calcuate its Brightness and Saturation
2. Track Form background ColorTrack Form background Color
3. Using different colors in Visual BasicUsing different colors in Visual Basic
4. Construct Color from R G B ValueConstruct Color from R G B Value
5. Use color dialog to set form backgroundUse color dialog to set form background
w_ww__.___j__a___va___2___s___.___c_o___m__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.