473,324 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Need help with colors.

I have a button or a Panel where I want to set the backcolor. I want to put
a kind of shade on the control.
On top I want light blue and dark blue at tbe bottom of the control.

Is there any way I can do it.

Thanks, Mark.
Jun 27 '08 #1
5 860

"Mark" <Ma**@nospaml.comwrote in message
news:O3**************@TK2MSFTNGP04.phx.gbl...
>I have a button or a Panel where I want to set the backcolor. I want to put
a kind of shade on the control.
On top I want light blue and dark blue at tbe bottom of the control.

Is there any way I can do it.

Thanks, Mark.
You can capture the Paint event. From that you can get the Graphics object
provided by the arguments to the event. From their (you will have to
research GDI+ you can do what ever you want with the drawing of the panel.
Note that this will not affect any controls you have placed in the panel.

Hope this helps
LS

Jun 27 '08 #2
On 2008-06-17, Mark <Ma**@nospaml.comwrote:
I have a button or a Panel where I want to set the backcolor. I want to put
a kind of shade on the control.
On top I want light blue and dark blue at tbe bottom of the control.

Is there any way I can do it.

Thanks, Mark.
What your talking about is a gradient. Here is a simple example - create a
form and drop a panel on it. I put a button in the panel as well, but it
doesn't do anything. I set the panel to anchor on all for sides:

Option Explicit On
Option Strict On
Option Infer Off

Imports System
Imports System.Drawing
Imports System.Drawing.Drawing2D

Public Class Form1
Private Sub Panel1_Paint( _
ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint

Using gradient As Brush = New LinearGradientBrush( _
Panel1.ClientRectangle, _
Color.LightBlue, _
Color.DarkBlue, LinearGradientMode.Vertical)
e.Graphics.FillRectangle(gradient, Panel1.ClientRectangle)
End Using
End Sub

Private Sub Form1_SizeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged
Me.Panel1.Invalidate(Panel1.ClientRectangle)
End Sub
End Class

You will notice some flickering as you resize - I make no attempt to reduce
that. You could by using double buffering techniques.

--
Tom Shelton
Jun 27 '08 #3
Thanks Tom.

Mark

"Tom Shelton" <to*********@comcastXXXXXXX.netwrote in message
news:yp******************************@comcast.com. ..
On 2008-06-17, Mark <Ma**@nospaml.comwrote:
>I have a button or a Panel where I want to set the backcolor. I want to
put
a kind of shade on the control.
On top I want light blue and dark blue at tbe bottom of the control.

Is there any way I can do it.

Thanks, Mark.

What your talking about is a gradient. Here is a simple example - create
a
form and drop a panel on it. I put a button in the panel as well, but it
doesn't do anything. I set the panel to anchor on all for sides:

Option Explicit On
Option Strict On
Option Infer Off

Imports System
Imports System.Drawing
Imports System.Drawing.Drawing2D

Public Class Form1
Private Sub Panel1_Paint( _
ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint

Using gradient As Brush = New LinearGradientBrush( _
Panel1.ClientRectangle, _
Color.LightBlue, _
Color.DarkBlue, LinearGradientMode.Vertical)
e.Graphics.FillRectangle(gradient, Panel1.ClientRectangle)
End Using
End Sub

Private Sub Form1_SizeChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.SizeChanged
Me.Panel1.Invalidate(Panel1.ClientRectangle)
End Sub
End Class

You will notice some flickering as you resize - I make no attempt to
reduce
that. You could by using double buffering techniques.

--
Tom Shelton

Jun 27 '08 #4
SmartContainer drops shade for controls automatically.

Could find it from www.springsys.com
>I have a button or a Panel where I want to set the backcolor. I want to put
a kind of shade on the control.
On top I want light blue and dark blue at tbe bottom of the control.

Is there any way I can do it.

Thanks, Mark.

Jun 27 '08 #5

"Martin M" <no****@no.spam.comwrote in message
news:eA**************@TK2MSFTNGP05.phx.gbl...
SmartContainer drops shade for controls automatically.

Could find it from www.springsys.com
>>I have a button or a Panel where I want to set the backcolor. I want to
put a kind of shade on the control.
On top I want light blue and dark blue at tbe bottom of the control.

Is there any way I can do it.

Thanks, Mark.

I would think with all your postings (which if they are not spam I would be
surprised) will certainly put springsys on most peoples avoid list.

Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Allan | last post by:
Please help, below is my problem. Let's say I have 2 tables, a Products table and a Colors table that go as follow: Table Products prodID Name 1 shirt 2 tshirt
3
by: Marc | last post by:
Hi, maybe you guys know something I don't know... Is it possible (and how) to achieve the following: 1) A <BODY> with specific background-color, say blue. 2) A <DIV class='main'> (which...
2
by: Danny | last post by:
HI, I am trying to do a group by such as this: "select code, colors from productdb group by code, colors" I need to sort on the key field, but cannot throw in the 'ordre by key', because i...
23
by: Adam | last post by:
I am coding a microkernel based off of Tanebaum's theroy. For Isis to be extensible, fast, and secure, it has been decided it will be a microkernel. Not in the old Mach sense of the word, but in...
1
by: ebernedo | last post by:
Hey guys, I have two main questions First off (pictures are kind of blurry) I have this table http://i197.photobucket.com/albums/aa109/ebernedo/DiscTable.jpg And thats my database I use my...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.