Christian Torres M Christian Torres M - 1 month ago 16
C# Question

How to add two ToolStripComboBox and separator to one ToolStripDropDown item?

I think that this should be simple to do. But I haven't seen it. I'd like to do something like:

DropDown -> DropDownItem1 [ComboBox1 [|] ComboBox2], DropDownItem2 [...], DropDownItem3 [...];

I'm using ToolStripDropDownButton in a ToolStrip. I'm programming w/ C# . Thanks for your advices.

Something like: https://s18.postimg.org/nd9r35jpl/c89a195a3b6e8dac6e7753af6b0b8a6c.png

Best Regards

Answer

Use the wizard and look at the final code:

// 
// toolStrip1
// 
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripComboBox1,
this.toolStripComboBox2,
this.toolStripSeparator1,
this.toolStripDropDownButton1});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(771, 25);
this.toolStrip1.TabIndex = 2;
this.toolStrip1.Text = "toolStrip1";
// 
// toolStripComboBox1
// 
this.toolStripComboBox1.Name = "toolStripComboBox1";
this.toolStripComboBox1.Size = new System.Drawing.Size(121, 25);
// 
// toolStripComboBox2
// 
this.toolStripComboBox2.Name = "toolStripComboBox2";
this.toolStripComboBox2.Size = new System.Drawing.Size(121, 25);
// 
// toolStripSeparator1
// 
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
// 
// toolStripDropDownButton1
// 
this.toolStripDropDownButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripDropDownButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripDropDownButton1.Image")));
this.toolStripDropDownButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripDropDownButton1.Name = "toolStripDropDownButton1";
this.toolStripDropDownButton1.Size = new System.Drawing.Size(29, 22);
this.toolStripDropDownButton1.Text = "toolStripDropDownButton1";