Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 874
  • Last Modified:

ToolStripTextBox and ToolStripButton Side-By-Side

I have the following code and I would like to have the ToolStripTextBox and ToolStripButton drawn next ot each other... Any ideas?

Bitmap img = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream(
                   "search_active.jpg"));

private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
            this.toolStripMenuItemReset = new System.Windows.Forms.ToolStripMenuItem();
            this.searchFieldMenuStrip = new System.Windows.Forms.ToolStripMenuItem();
            this.txtSearch = new System.Windows.Forms.ToolStripTextBox();
            this.btnSearch = new System.Windows.Forms.ToolStripButton();
            this.searchSubMenuStrip = new System.Windows.Forms.MenuStrip();            
            this.contextMenuStrip.SuspendLayout();
            this.AllowUserToOrderColumns = true;
            this.SuspendLayout();

            //
            // contextMenuStrip
            //
            this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                    this.searchFieldMenuStrip,
                    this.toolStripSeparator1,
                    this.toolStripMenuItemReset});
            this.contextMenuStrip.Name = "contextMenuStrip1";
            this.contextMenuStrip.Size = new System.Drawing.Size(390, 54);
            //
            // toolStripSeparator1
            //
            this.toolStripSeparator1.Name = "toolStripSeparator1";
            this.toolStripSeparator1.Size = new System.Drawing.Size(365, 6);
            //
            // toolStripMenuItemReset
            //
            this.toolStripMenuItemReset.Name = "toolStripMenuItem1";
            this.toolStripMenuItemReset.Size = new System.Drawing.Size(365, 22);
            this.toolStripMenuItemReset.Text = "Reset Search";
            this.toolStripMenuItemReset.Click += new System.EventHandler(toolStripMenuItemReset_Click);
            //
            // searchFieldMenuStrip
            //
            this.searchFieldMenuStrip.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.txtSearch, this.btnSearch});                
            this.searchFieldMenuStrip.Name = "toolStripMenuItem2";
            this.searchFieldMenuStrip.Size = new System.Drawing.Size(365, 22);
            this.searchFieldMenuStrip.Text = "Search for:";
            //
            // txtSearch
            //
            this.txtSearch.Name = "txtSearch";
            this.txtSearch.Size = new System.Drawing.Size(100, 21);
            this.txtSearch.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtSearch_KeyPress);
            //
            // btnSearch
            //
            this.btnSearch.Image = img;
            this.btnSearch.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
            this.btnSearch.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.ImageAndText;
            this.btnSearch.Dock = System.Windows.Forms.DockStyle.Right;
            this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
            //
            // searchSubMenuStrip
            //
            this.searchSubMenuStrip.Location = new System.Drawing.Point(0, 0);
            this.searchSubMenuStrip.Name = "menuStrip1";
            this.searchSubMenuStrip.Size = new System.Drawing.Size(292, 24);
            this.searchSubMenuStrip.TabIndex = 1;
            this.searchSubMenuStrip.Text = "menuStrip1";          
            //
            // SearchGridControl
            //
            this.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.SearchGridControl_ColumnHeaderMouseClick);
            this.ScrollBars = System.Windows.Forms.ScrollBars.Both;
            this.contextMenuStrip.ResumeLayout(false);
            this.contextMenuStrip.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
            this.ResumeLayout(false);

        }

     

        #endregion

        private System.Windows.Forms.ContextMenuStrip contextMenuStrip;
        private System.Windows.Forms.ToolStripMenuItem searchFieldMenuStrip;
        private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemReset;
        private System.Windows.Forms.ToolStripTextBox txtSearch;
        private System.Windows.Forms.MenuStrip searchSubMenuStrip;
        private System.Windows.Forms.ToolStripButton btnSearch;


Thanks,

Yama
0
yamazed
Asked:
yamazed
  • 3
1 Solution
 
Priest04Commented:
What do you mean by: >> rawn next ot each other? Do you mean ToolStripButton to be on top of the ToolStripTextBox? As far as I know, it is not possible. You can simulate something like that by creating a System.Windows.Forms.Button control, and placing it on top of the ToolStripTextBox.

Goran
0
 
yamazedAuthor Commented:
What I mean is something like this:

Search (a ToolStripMenuItem ) --> (ToolStripMenuItem ) myTextbox (space) mybutton (both in a single line)

Currently when adding them as in this.searchFieldMenuStrip.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {this.txtSearch, this.btnSearch});    both context get displayed in a new line... What I would like is the display to be on a single line...

Thanks,

Yama
0
 
Priest04Commented:
So if I understood you well, you have a MenuStrip control, and you want items in dropdownlist to be displayed horisontally? :) No, that is not possible either. Even ToolStripButton is not natively supported with MenuStrip, only MenuItem, ComboBox, Separator and TextBox. Maybe you should try ToolStrip control instead.

Goran
0
 
Priest04Commented:
Altough if you use DropDownButton in ToolStrip, it has the same behavour as TollStripMenuItem, so you will end up as with MenuStrip.

Goran
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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