ComponentOne Menus and Toolbars for WinForms
Menus and Toolbars for WinForms Task-Based Help / ToolBar Tasks / Making the ToolBar Appear Like the Default Toolbar in Internet Explorer(IE)
In This Topic
    Making the ToolBar Appear Like the Default Toolbar in Internet Explorer(IE)
    In This Topic

    This topic demonstrates how to make the C1ToolBar appear like the default toolbar in IE by using the ButtonLookFlags enumeration. The ButtonLookFlags enumeration contains the parameters: Text, TextAndImage, Image, and Default. These parameters give you the ability to modify your toolbar button to show text, text and an image, or just an image.

    The following code demonstrates how you can make the C1ToolBar appear like the default toolbar in IE. The following example uses all of the parameters (TextAndImage, Image, Default, and Text) contained in the ButtonLookFlags enumeration to make the C1ToolBar appear similar to the IE toolbar:

    1. Create the first toolbar button and make it appear as an image. The following code shows you how to use the ButtonLookFlags enumeration to make the toolbar button appear as an image:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Dim ch As C1CommandHolder = C1CommandHolder.CreateCommandHolder(Me)
      Dim tb As New C1ToolBar()
      Me.Controls.Add(tb)
      tb.CommandHolder = ch
      Dim cNew As New C1Command()
      Dim cl As C1CommandLink
      cNew.Text = "New"
      cNew.Image = System.Drawing.Image.FromFile("C:\Images\New.bmp")
      cl = New C1CommandLink(cNew)
      tb.CommandLinks.Add(cl)
      'Use the ButtonLookFlags enumeration to make the toolbar button appear as an image
      cl.ButtonLook = ButtonLookFlags.Image
      

      To write code in C#

      C#
      Copy Code
      C1CommandHolder ch = C1CommandHolder.CreateCommandHolder(this);
      C1ToolBar tb = new C1ToolBar();
      this.Controls.Add(tb);
      tb.CommandHolder = ch;
      C1Command cNew = new C1Command();
      cNew.Text = " New ";
      cl = new C1CommandLink(cNew);
      tb.Commandlinks.Add(cl);
      //Use the ButtonLookFlags enumeration to make the toolbar button appear as an image
      cl.ButtonLook = ButtonLookFlags.Image;
      
    2. Create a second toolbar button and make it appear as text and image. The following code shows you how to use the ButtonLookFlags enumeration to make the toolbar button appear as text and an image:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Dim cOpen As New C1Command()
      cOpen.Text = "Open"
      cl = New C1CommandLink(cOpen)
      cOpen.Image =  System.Drawing.Image.FromFile("C:\Images\FileOpen.bmp")
      tb.CommandLinks.Add(cl)
      'Use the ButtonLookFlags enumeration to make the toolbar button appear as text and an image
      cl.ButtonLook = ButtonLookFlags.TextAndImage
      

      To write code in C#

      C#
      Copy Code
      C1Command cOpen = new C1Command();
      cOpen.Text = "Open";
      cl = new C1CommandLink(cOpen);
      cOpen.Image = System.Drawing.Image.FromFile("C:\Images\FileOpen.bmp");
      tb.CommandLinks.Add(cl);
      //Use the ButtonLookFlags enumeration to make the toolbar button appear as text and an image
      cl.ButtonLook = ButtonLookFlags.TextAndImage;
      
    3. Create a third toolbar button and make it appear as the default appearance. The following code shows you how to use the ButtonLookFlags enumeration to make the toolbar button appear as the default appearance:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Dim cSave As New C1Command()
      cSave.Text = "Save"
      cl = New C1CommandLink(cSave)
      tb.CommandLinks.Add(cl)
      cSave.Image = System.Drawing.Image.FromFile("C:\Images\FileSave.bmp")
      'Use the ButtonLookFlags enumeration to make the toolbar button appear as default
      cl.ButtonLook = ButtonLookFlags.Default
      

      To write code in C#

      C#
      Copy Code
      C1Command cSave = new C1Command();
      cSave.Text = "Save";
      cl = new C1CommandLink(cSave);
      tb.CommandLinks.Add(cl);
      cSave.Image = System.Drawing.Image.FromFile("C:\Images\FileSave.bmp")
      //Use the ButtonLookFlags enumeration to make the toolbar button appear as default
      cl.ButtonLook = ButtonLookFlags.Default;
      
    4. Create a fourth toolbar button and make it appear as text. The following code shows you how to use the ButtonLookFlags enumeration to make the toolbar button appear as text:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Dim cFavorites As New C1Command()
      cFavorites.Text = "Favorites"
      cl = New C1CommandLink(cFavorites)
      tb.CommandLinks.Add(cl)
      'Use the ButtonLookFlags enumeration to make the toolbar button appear as text
      cl.ButtonLook = ButtonLookFlags.Text
      

      To write code in C#

      C#
      Copy Code
      C1Command cFavorites = new C1Command();
      cFavorites.Text = "Save";
      cl = new C1CommandLink(cFavorites);
      tb.CommandLinks.Add(cl);
      //Use the ButtonLookFlags enumeration to make the toolbar button appear as text
      cl.ButtonLook = ButtonLookFlags.Text;
      
    5. Save and run your application. Your C1ToolBar will appear similar to the following toolbar:
      Toolbar
    Note: Your toolbar images will appear different from the toolbar images in this image. The first, second, third, and fourth toolbar buttons are shown as an image, text and image, default, and text, respectively.
    See Also