• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 996
  • Last Modified:

Integrate a ComboBox into a C# .net2.0 ToolStrip

I am trying to integrate a ComboBox into a C# .net2.0 ToolStrip. (I am actually using  a custom ComboBox , that inherits from type  ComboBox).  It appears that the ToolStrip has specialized components (button, comboBox, etc).   The toolstripComboBox does not appear to have the same functionality  as a standard ComboBox.  I need the added functionality of the non-ToolStrip ComboBox. I am using it for a Font Selector which shows the graphical representations of the fonts
I would really like to add the ComboBox into the toolStrip.  Has anyone been successful at this?   I can place it at the end of the other combobox Items.  It appears to be part of the toolstrip but its not really integrated into the toolStrip.   I really would like to place it in the middle of the toolStrip and its not apparent how I could do this.
If I try to set the ComboBox parent to the ToolStrip I get a collection is read only error.  
Any ideas how I might make this work?  Or at least act like it works ;-).
Thanks
0
dannyhop
Asked:
dannyhop
  • 3
  • 2
1 Solution
 
grayeCommented:
There is the "hard way"... where you create a class that inherts from ToolStripItem...  and the "easy way", where you just poke an existing control into the toolstrip.
Take a look at the following article for the easy way:
 http://kozmic.pl/archive/2007/06/01/how-to-embed-custom-control-in-toolstrip.aspx
0
 
Miguel OzSoftware EngineerCommented:
You need to build a custom-toolstrip that inherits from ToolStripControlHost:
http://bytes.com/topic/visual-basic-net/answers/601299-building-custom-toolstrip-control
Another way to do it: (Just replace the datetime picker with your combobox)
http://kozmic.pl/archive/2007/06/01/how-to-embed-custom-control-in-toolstrip.aspx
0
 
dannyhopAuthor Commented:
I'll try these and let you know if it worked
Thanks
0
Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
dannyhopAuthor Commented:
I am half way there.  Using the 'how-to-embed-custom-control-in-toolstrip' article,  I can place the item in the toolstrip but only at the end.  It looks like the order of apperance in the toolStrip is established in the forms designer .cs file.   I do not see how to specify its order within the toolstrip.  Is there anything that I can do to control the order of apperance of this item within in the toolStrip.
Thanks Again
0
 
grayeCommented:
ToolStrip.Items is a collection.   That means you can use the .Insert() method to put it at the location you want.
0
 
dannyhopAuthor Commented:
That did it.  I just replaced
"toolStrip1.Items.Add"
with
"toolStrip1.Items.Insert" , gave it the proper index... and shazam... works great.
Thanks for your kind assistance grave.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now