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. how to add costum control to custom control via designer. [modified]

how to add costum control to custom control via designer. [modified]

Scheduled Pinned Locked Moved C#
tutorial
5 Posts 2 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.
  • N Offline
    N Offline
    Natural_Demon
    wrote on last edited by
    #1

    i'm trying to create 2 custom controls, once you compile, you have a nice custom control up in the visualstudio I.D.E.. i would like to achieve, the once a dragged 'MenuStrip' onto my form and start adding item, that these items are also a new created costrum control 'cToolStripMenuItem', instead of standart item using System; using System.Collections.Generic; using System.Windows.Forms; using System.Text; namespace OwnerDraw_Test_3 { class CMenuStrip : MenuStrip { } class cToolStripMenuItem : ToolStripMenuItem { } } kind regards

    Bad = knowing 2 much

    modified on Thursday, September 24, 2009 2:41 PM

    H 1 Reply Last reply
    0
    • N Natural_Demon

      i'm trying to create 2 custom controls, once you compile, you have a nice custom control up in the visualstudio I.D.E.. i would like to achieve, the once a dragged 'MenuStrip' onto my form and start adding item, that these items are also a new created costrum control 'cToolStripMenuItem', instead of standart item using System; using System.Collections.Generic; using System.Windows.Forms; using System.Text; namespace OwnerDraw_Test_3 { class CMenuStrip : MenuStrip { } class cToolStripMenuItem : ToolStripMenuItem { } } kind regards

      Bad = knowing 2 much

      modified on Thursday, September 24, 2009 2:41 PM

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      And your problem is? What have you tried?

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      N 1 Reply Last reply
      0
      • H Henry Minute

        And your problem is? What have you tried?

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        N Offline
        N Offline
        Natural_Demon
        wrote on last edited by
        #3

        wel, i'm trying to achieve, that items added to the menuStrip, are the items from my class and not the standart System.Windows.Forms.ToolStripMenuItem(). without anyneed to manualy moding the form1.designer.cs this.ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.ToolStripMenuItem1 = new OwnerDraw_Test_3.cToolStripMenuItem();

        Bad = knowing 2 much

        H 1 Reply Last reply
        0
        • N Natural_Demon

          wel, i'm trying to achieve, that items added to the menuStrip, are the items from my class and not the standart System.Windows.Forms.ToolStripMenuItem(). without anyneed to manualy moding the form1.designer.cs this.ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.ToolStripMenuItem1 = new OwnerDraw_Test_3.cToolStripMenuItem();

          Bad = knowing 2 much

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #4

          Well, you are deriving your own class from MenuStrip, so you are in control of what happens in there. All you have to do is override any methods/events where a MenuItem is added/inserted/deleted. That is a lot of work, though. Alternatively you can just create your own OwnerDraw_Test_3.cToolStripMenuItem(), as you are doing. What else you need to do will depend on whether you are only going to add them in code, or if you need design time support. For design time support, look up the documentation for the ToolStripItemDesignerAvailability attribute. From there you should find links that will help you in designing the cToolStripMenuItem. For code only implementation, it is surely only a matter of casting to cToolStripMenuItem wherever there is interaction with your control. Sorry not to be more help, but my internet connection is playing up, and it takes about 5 mins to get a google search up at the moment, otherwise I would have given you more specific links. :)

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          N 1 Reply Last reply
          0
          • H Henry Minute

            Well, you are deriving your own class from MenuStrip, so you are in control of what happens in there. All you have to do is override any methods/events where a MenuItem is added/inserted/deleted. That is a lot of work, though. Alternatively you can just create your own OwnerDraw_Test_3.cToolStripMenuItem(), as you are doing. What else you need to do will depend on whether you are only going to add them in code, or if you need design time support. For design time support, look up the documentation for the ToolStripItemDesignerAvailability attribute. From there you should find links that will help you in designing the cToolStripMenuItem. For code only implementation, it is surely only a matter of casting to cToolStripMenuItem wherever there is interaction with your control. Sorry not to be more help, but my internet connection is playing up, and it takes about 5 mins to get a google search up at the moment, otherwise I would have given you more specific links. :)

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

            N Offline
            N Offline
            Natural_Demon
            wrote on last edited by
            #5

            hi, yes thank you [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.All)] class cToolStripMenuItem : ToolStripMenuItem { } how ever, somehow it failed : ( http://social.msdn.microsoft.com/Forums/en-US/winformsdesigner/thread/bbad3255-17f5-4177-b7cf-cad20c858746[^] http://books.google.nl/books?id=zDi4LIDvd4wC&pg=PA507&lpg=PA507&dq=ToolStripItemDesignerAvailability+attribute&source=bl&ots=hJLpeqQqrM&sig=3BoIynZA4rP-V55447AN8gON9KE&hl=nl&ei=2jO9Ss6TINvOjAfBoME4&sa=X&oi=book_result&ct=result&resnum=2#v=onepage&q=ToolStripItemDesignerAvailability%20attribute&f=false[^]

            Bad = knowing 2 much

            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