Designed Toolbar : Toolbar « GUI Windows Forms « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » GUI Windows Forms » Toolbar 
23.38.10.Designed Toolbar
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

  public class DesignedToolbarForm : System.Windows.Forms.Form
  {
    private System.Windows.Forms.ToolBar tbDefault;
    private System.Windows.Forms.ImageList imgListToolbar;
    private System.Windows.Forms.ToolBarButton tbbNew;
    private System.Windows.Forms.ToolBarButton tbbOpen;
    private System.Windows.Forms.ToolBarButton tbbSave;
    private System.Windows.Forms.ToolBarButton tbbSeparator;
    private System.Windows.Forms.ToolBarButton tbbCut;
    private System.Windows.Forms.ToolBarButton tbbCopy;
    private System.Windows.Forms.ToolBarButton tbbPaste;
    private System.Windows.Forms.ToolBarButton tbbHelp;
    private System.Windows.Forms.MenuItem menuItem1;
    private System.Windows.Forms.MainMenu mnuDemo;

    public DesignedToolbarForm()
    {
      this.tbDefault = new System.Windows.Forms.ToolBar();
      this.tbbNew = new System.Windows.Forms.ToolBarButton();
      this.tbbOpen = new System.Windows.Forms.ToolBarButton();
      this.tbbSave = new System.Windows.Forms.ToolBarButton();
      this.tbbSeparator = new System.Windows.Forms.ToolBarButton();
      this.tbbCut = new System.Windows.Forms.ToolBarButton();
      this.tbbCopy = new System.Windows.Forms.ToolBarButton();
      this.tbbPaste = new System.Windows.Forms.ToolBarButton();
      this.tbbHelp = new System.Windows.Forms.ToolBarButton();
      this.imgListToolbar = new System.Windows.Forms.ImageList();
      this.mnuDemo = new System.Windows.Forms.MainMenu();
      this.menuItem1 = new System.Windows.Forms.MenuItem();
      this.SuspendLayout();
      // 
      // tbDefault
      // 
      this.tbDefault.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
                                             this.tbbNew,
                                             this.tbbOpen,
                                             this.tbbSave,
                                             this.tbbSeparator,
                                             this.tbbCut,
                                             this.tbbCopy,
                                             this.tbbPaste,
                                             this.tbbHelp});
      this.tbDefault.DropDownArrows = true;
      this.tbDefault.ImageList = this.imgListToolbar;
      this.tbDefault.Name = "tbDefault";
      this.tbDefault.ShowToolTips = true;
      this.tbDefault.Size = new System.Drawing.Size(36039);
      this.tbDefault.TabIndex = 0;
      this.tbDefault.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.OnButtonClick);
      // 
      // tbbNew
      // 
      this.tbbNew.ImageIndex = 0;
      this.tbbNew.Text = "New";
      this.tbbNew.ToolTipText = "Create a new file";
      // 
      // tbbOpen
      // 
      this.tbbOpen.ImageIndex = 1;
      this.tbbOpen.Text = "Open";
      this.tbbOpen.ToolTipText = "Open an existing file";
      // 
      // tbbSave
      // 
      this.tbbSave.ImageIndex = 2;
      this.tbbSave.Text = "Save";
      this.tbbSave.ToolTipText = "Save active document";
      // 
      // tbbSeparator
      // 
      this.tbbSeparator.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
      // 
      // tbbCut
      // 
      this.tbbCut.ImageIndex = 3;
      this.tbbCut.Text = "Cut";
      this.tbbCut.ToolTipText = "Cut selection";
      // 
      // tbbCopy
      // 
      this.tbbCopy.ImageIndex = 4;
      this.tbbCopy.Text = "Copy";
      this.tbbCopy.ToolTipText = "Copy selection";
      // 
      // tbbPaste
      // 
      this.tbbPaste.ImageIndex = 5;
      this.tbbPaste.Text = "Paste";
      this.tbbPaste.ToolTipText = "Paste from clipboard";
      // 
      // tbbHelp
      // 
      this.tbbHelp.ImageIndex = 6;
      this.tbbHelp.Text = "Help";
      this.tbbHelp.ToolTipText = "Help";
      // 
      // imgListToolbar
      // 
      this.imgListToolbar.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
      this.imgListToolbar.ImageSize = new System.Drawing.Size(1616);
      this.imgListToolbar.TransparentColor = System.Drawing.Color.Transparent;
      // 
      // mnuDemo
      // 
      this.mnuDemo.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                          this.menuItem1});
      // 
      // menuItem1
      // 
      this.menuItem1.Index = 0;
      this.menuItem1.Text = "File";
      // 
      // DesignedToolbarForm
      // 
      this.AutoScaleBaseSize = new System.Drawing.Size(513);
      this.ClientSize = new System.Drawing.Size(360273);
      this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                      this.tbDefault});
      this.Menu = this.mnuDemo;
      this.Name = "DesignedToolbarForm";
      this.Text = "Designed Toolbar";
      this.ResumeLayout(false);

    }
    static void Main() 
    {
      Application.Run(new DesignedToolbarForm());
    }

    private void OnButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
    {
      ToolBarButton tbCurrent = e.Button;
      MessageBox.Show("You clicked button " + tbCurrent.Text);
    }
  }
23.38.Toolbar
23.38.1.Toolbar with ComboBoxToolbar with ComboBox
23.38.2.ToolBar Linked With MenuToolBar Linked With Menu
23.38.3.ToolBar Button ActionToolBar Button Action
23.38.4.Add Button action to ToolBar ButtonAdd Button action to ToolBar Button
23.38.5.Add ToolTip to ToolBar ButtonAdd ToolTip to ToolBar Button
23.38.6.Create an ImageList and use it for ToolBarCreate an ImageList and use it for ToolBar
23.38.7.Add Image to ToolBar ButtonAdd Image to ToolBar Button
23.38.8.ToolBar Button border style: BorderStyle.Fixed3DToolBar Button border style: BorderStyle.Fixed3D
23.38.9.Cut, Copy Paste/Text Box with Toolbar
23.38.10.Designed Toolbar
23.38.11.ToolBar Button Style
23.38.12.Toolbar Styles
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.