.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Articles >> General >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Gradient Color On Form using Colors from the DropDownlist

Posted By:Hefin Dsouza       Posted Date: August 11, 2009    Points: 25    Category: General    URL: http://www.dotnetspark.com  

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
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
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
 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend