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. Simple custom ownerdraw button

Simple custom ownerdraw button

Scheduled Pinned Locked Moved C#
questionhelp
2 Posts 2 Posters 1 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.
  • B Offline
    B Offline
    babbelfisken
    wrote on last edited by
    #1

    I have a class myButton:Button { myButton(object obj) { //... } protected void override OnPaint(PaintEventArgs ev) { // code } } What i want: I have a form with a simple button. When i enter the event_click this button i create a myButton control object that i want to be drawn somewhere on the form. The reason why i need a custom control is that i want the myButton obj to contain the object that i send to the constructor. How do i draw this button to the form, what do i call and so forth? The properties i want to set for this myButton is that it is flat for now.. To this myButton i want to register the double_click event. Have searched the internet but i am a bit confused, i thought i understood but nothing draws. Please som help!

    E 1 Reply Last reply
    0
    • B babbelfisken

      I have a class myButton:Button { myButton(object obj) { //... } protected void override OnPaint(PaintEventArgs ev) { // code } } What i want: I have a form with a simple button. When i enter the event_click this button i create a myButton control object that i want to be drawn somewhere on the form. The reason why i need a custom control is that i want the myButton obj to contain the object that i send to the constructor. How do i draw this button to the form, what do i call and so forth? The properties i want to set for this myButton is that it is flat for now.. To this myButton i want to register the double_click event. Have searched the internet but i am a bit confused, i thought i understood but nothing draws. Please som help!

      E Offline
      E Offline
      Eitsop
      wrote on last edited by
      #2

      babbelfisken wrote:

      protected void override OnPaint(PaintEventArgs ev) { // code } }

      You'll be wanting to look at ev.Graphics - the Graphics object. This will allow you to manually draw the button. For example: ev.Graphics.DrawRectangle(Pens.Black, this.ClientRectangle); But it gets more complex - double buffering, multiple states (enabled, disabled etc..). Is that a good starting point? Eitsop

      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