how to add costum control to custom control via designer. [modified]
-
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
-
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
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.”
-
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.”
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
-
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
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 ownOwnerDraw_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 theToolStripItemDesignerAvailability
attribute. From there you should find links that will help you in designing thecToolStripMenuItem
. For code only implementation, it is surely only a matter of casting tocToolStripMenuItem
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.”
-
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 ownOwnerDraw_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 theToolStripItemDesignerAvailability
attribute. From there you should find links that will help you in designing thecToolStripMenuItem
. For code only implementation, it is surely only a matter of casting tocToolStripMenuItem
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.”
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