Need help with colors.

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

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.
 
Mark said:
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
 
Thanks Tom.

Mark

Tom Shelton said:
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.
 
Martin M said:
SmartContainer drops shade for controls automatically.

Could find it from www.springsys.com

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.
 
Back
Top