C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Graphics »

Gradient Color on Form Using ComboBoxes in VB.Net


Posted Date: 26 Apr 2009    Resource Type: Code Snippets    Category: Graphics
Author: Hefin DsouzaMember Level: Diamond    
Rating: 1 out of 5Points: 15



The following example contains two Comboboxes which List the available KnowColors by using the Following Code.
Note:Code to Add all available Know Colors to Combobox

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim col As KnownColor
For col = KnownColor.ActiveBorder To KnownColor.YellowGreen
ComboBox1.Items.Add(col)
ComboBox2.Items.Add(col)
Next
End Sub


Note:In the Selected Index Changed Event of Both the Combobox write the Following Code

Private Sub ComboBoxChanger(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged, ComboBox2.SelectedIndexChanged
Dim g As Graphics = Me.CreateGraphics()
Dim cl1 As KnownColor = ComboBox1.SelectedItem ' The Selected Item is converted to a KnownColor
Dim cl2 As KnownColor = ComboBox2.SelectedItem ' The Selected Item is converted to a KnownColor
Refresh()
Dim graidentBrush As New Drawing2D.LinearGradientBrush(ClientRectangle, Color.FromKnownColor(cl1), Color.FromKnownColor(cl2), Drawing2D.LinearGradientMode.BackwardDiagonal)' This is for The Gradient Effect
g.FillRectangle(graidentBrush, ClientRectangle)
End Sub


Regards Hefin Dsouza
Download the Sample Source Code

Attachments

  • Download Source Codes (28007-26182-GradientFun.rar)


  • Responses


    No responses found. Be the first to respond and make money from revenue sharing program.

    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Sign In to add tags.
    VB.Net  .  SelectedIndexChanged  .  List of all Colors  .  Linear Gradient  .  KnownColor  .  GDI+  .  Combobox  .  Color Animation  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: Graph Control(ZedGraph Control)
    Previous Resource: Handle Click Event for Eclipse:Window Application
    Return to Discussion Resource Index
    Post New Resource
    Category: Graphics


    Post resources and earn money!
     
    More Resources



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use