Need help with colors.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark

    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.


  • Lloyd Sheen

    #2
    Re: Need help with colors.


    "Mark" <Mark@nospaml.c omwrote in message
    news:O3$hgLK0IH A.5716@TK2MSFTN GP04.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

    Comment

    • Tom Shelton

      #3
      Re: Need help with colors.

      On 2008-06-17, Mark <Mark@nospaml.c omwrote:
      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.PaintEven tArgs) Handles Panel1.Paint

      Using gradient As Brush = New LinearGradientB rush( _
      Panel1.ClientRe ctangle, _
      Color.LightBlue , _
      Color.DarkBlue, LinearGradientM ode.Vertical)
      e.Graphics.Fill Rectangle(gradi ent, Panel1.ClientRe ctangle)
      End Using
      End Sub

      Private Sub Form1_SizeChang ed(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.SizeChan ged
      Me.Panel1.Inval idate(Panel1.Cl ientRectangle)
      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

      Comment

      • Mark

        #4
        Re: Need help with colors.

        Thanks Tom.

        Mark

        "Tom Shelton" <tom_shelton@co mcastXXXXXXX.ne twrote in message
        news:yp-dnXn6_elhnMXVnZ 2dnUVZ_i2dnZ2d@ comcast.com...
        On 2008-06-17, Mark <Mark@nospaml.c omwrote:
        >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.PaintEven tArgs) Handles Panel1.Paint
        >
        Using gradient As Brush = New LinearGradientB rush( _
        Panel1.ClientRe ctangle, _
        Color.LightBlue , _
        Color.DarkBlue, LinearGradientM ode.Vertical)
        e.Graphics.Fill Rectangle(gradi ent, Panel1.ClientRe ctangle)
        End Using
        End Sub
        >
        Private Sub Form1_SizeChang ed(ByVal sender As System.Object, ByVal e As
        System.EventArg s) Handles MyBase.SizeChan ged
        Me.Panel1.Inval idate(Panel1.Cl ientRectangle)
        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

        Comment

        • Martin M

          #5
          Re: Need help with colors.

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

          Comment

          • Lloyd Sheen

            #6
            Re: Need help with colors.


            "Martin M" <nospam@no.spam .comwrote in message
            news:eApuGFY0IH A.3680@TK2MSFTN GP05.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.

            Comment

            Working...