Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. New gradient background for Button...?

New gradient background for Button...?

Scheduled Pinned Locked Moved C#
cssquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Edmundisme
    wrote on last edited by
    #1

    Hello, I want to change the gradient background of my button. It's easy to change the background color, but using a custom gradient is obviously less straight forward. Could someone point me in the right direction? Thanks! Ian

    J A R 3 Replies Last reply
    0
    • E Edmundisme

      Hello, I want to change the gradient background of my button. It's easy to change the background color, but using a custom gradient is obviously less straight forward. Could someone point me in the right direction? Thanks! Ian

      J Offline
      J Offline
      Joachim Kerschbaumer
      wrote on last edited by
      #2

      well, i´d say create a custom control, inherit from button and try something like his in the overridden OnPaint Method Graphics g = pe.Graphics; //getting graphics object of window background Rectangle bg = new Rectangle(0, 0, this.Width, this.Height); System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(bg, PageStartColor, PageEndColor, 0.0); g.FillRectangle(brush, bg); brush.Dispose();

      E 1 Reply Last reply
      0
      • E Edmundisme

        Hello, I want to change the gradient background of my button. It's easy to change the background color, but using a custom gradient is obviously less straight forward. Could someone point me in the right direction? Thanks! Ian

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #3

        here is code for you !!!! Bitmap bmp = new Bitmap(500, 500); Graphics G = Graphics.FromImage(bmp); LinearGradientBrush Lb = new LinearGradientBrush(new Point(0, 0), new Point(100, 100), Color.Red, Color.Green); G.FillRectangle(Lb, new Rectangle(0, 0, 100, 100)); button1.BackgroundImage = bmp;

        Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

        E 1 Reply Last reply
        0
        • E Edmundisme

          Hello, I want to change the gradient background of my button. It's easy to change the background color, but using a custom gradient is obviously less straight forward. Could someone point me in the right direction? Thanks! Ian

          R Offline
          R Offline
          Ravenet
          wrote on last edited by
          #4

          Hi Guy see this link http://www.codeproject.com/KB/buttons/multigradbuttonasp.aspx[^] Thanks

          Cheers RRave MCTS,MCPD

          E 1 Reply Last reply
          0
          • J Joachim Kerschbaumer

            well, i´d say create a custom control, inherit from button and try something like his in the overridden OnPaint Method Graphics g = pe.Graphics; //getting graphics object of window background Rectangle bg = new Rectangle(0, 0, this.Width, this.Height); System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(bg, PageStartColor, PageEndColor, 0.0); g.FillRectangle(brush, bg); brush.Dispose();

            E Offline
            E Offline
            Edmundisme
            wrote on last edited by
            #5

            Thanks for taking the time! I appreciate it! I'll try this solution.

            1 Reply Last reply
            0
            • A Abhijit Jana

              here is code for you !!!! Bitmap bmp = new Bitmap(500, 500); Graphics G = Graphics.FromImage(bmp); LinearGradientBrush Lb = new LinearGradientBrush(new Point(0, 0), new Point(100, 100), Color.Red, Color.Green); G.FillRectangle(Lb, new Rectangle(0, 0, 100, 100)); button1.BackgroundImage = bmp;

              Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

              E Offline
              E Offline
              Edmundisme
              wrote on last edited by
              #6

              Thanks for taking the time! I appreciate it! I'll give it a shot.

              1 Reply Last reply
              0
              • R Ravenet

                Hi Guy see this link http://www.codeproject.com/KB/buttons/multigradbuttonasp.aspx[^] Thanks

                Cheers RRave MCTS,MCPD

                E Offline
                E Offline
                Edmundisme
                wrote on last edited by
                #7

                Thanks for the link! I'll check it out.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups