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. Painting a button

Painting a button

Scheduled Pinned Locked Moved C#
graphicsquestion
4 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.
  • K Offline
    K Offline
    kalyanPaladugu
    wrote on last edited by
    #1

    Iam trying to paint a button to get a shade in a button. Iam using a LinearGradientBrush. The code below Worked but it is taking away the button1.text also.How do i get the text to show after the button is painted. void button1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Rectangle rcView = this.ClientRectangle; using (LinearGradientBrush brush = new LinearGradientBrush(rcView, this.ColorStart, this.ColorEnd, this.GradientMode)) { g.FillRectangle(brush, rcView); } base.OnPaint(e); } ColorStart and ColorEnd are basically colors. Iam trying shade of the color from lighter to darker across the button. So my ColorStart is a little lighter color and ColorEnd is a Darker color. Thanks Kal

    B N 2 Replies Last reply
    0
    • K kalyanPaladugu

      Iam trying to paint a button to get a shade in a button. Iam using a LinearGradientBrush. The code below Worked but it is taking away the button1.text also.How do i get the text to show after the button is painted. void button1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Rectangle rcView = this.ClientRectangle; using (LinearGradientBrush brush = new LinearGradientBrush(rcView, this.ColorStart, this.ColorEnd, this.GradientMode)) { g.FillRectangle(brush, rcView); } base.OnPaint(e); } ColorStart and ColorEnd are basically colors. Iam trying shade of the color from lighter to darker across the button. So my ColorStart is a little lighter color and ColorEnd is a Darker color. Thanks Kal

      B Offline
      B Offline
      BarV
      wrote on last edited by
      #2

      Override the OnPaint function

      1 Reply Last reply
      0
      • K kalyanPaladugu

        Iam trying to paint a button to get a shade in a button. Iam using a LinearGradientBrush. The code below Worked but it is taking away the button1.text also.How do i get the text to show after the button is painted. void button1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Rectangle rcView = this.ClientRectangle; using (LinearGradientBrush brush = new LinearGradientBrush(rcView, this.ColorStart, this.ColorEnd, this.GradientMode)) { g.FillRectangle(brush, rcView); } base.OnPaint(e); } ColorStart and ColorEnd are basically colors. Iam trying shade of the color from lighter to darker across the button. So my ColorStart is a little lighter color and ColorEnd is a Darker color. Thanks Kal

        N Offline
        N Offline
        Nader Elshehabi
        wrote on last edited by
        #3

        Reposting your question 3 hours apart in the same forum is consedered very rude!!! Don't do that again, and review my answer to your previous post

        C 1 Reply Last reply
        0
        • N Nader Elshehabi

          Reposting your question 3 hours apart in the same forum is consedered very rude!!! Don't do that again, and review my answer to your previous post

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          It's happening a lot at the moment. I assume it means 'I don't understand the answer, and am hoping for one I can copy and paste'

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

          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