ComponentOne Menus and Toolbars for WinForms
Menus and Toolbars for WinForms Task-Based Help / OutBar Tasks / Customizing the Titles of OutPages
In This Topic
    Customizing the Titles of OutPages
    In This Topic

    In this topic, you will learn how to customize the title area of a C1OutBar control’s pages. You will create a C1OutBar with three C1OutPages, set a few properties, and then add code to the project that will paint custom colors to each title.

    Complete the following steps:

    1. Add a C1OutBar control to your form.
    2. Add three C1OutPage components to the C1OutBar control. (See Adding a C1OutPage to the C1OutBar.)
    3. Set the following properties:
      • Set c1OutBar1’s VisualStyle property to Classic. If you want, you can also choose Custom; the rest of the visual styles will not work for custom title drawing.
      • Set c1OutPage1’s OwnerDraw property to True.
      • Set c1OutPage2’s OwnerDraw property to True.
      • Set c1OutPage3’s OwnerDraw property to True.
    4. In the Properties window, select c1OutBar1 from the drop-down list, click the Events button, and then double-click the DrawPage event to add the DrawPage event handler to the project.
    5. Import the following namespace to the project:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Imports C1.Win.C1Command
      

      To write code in C#

      C#
      Copy Code
      using C1.Win.C1Command;
      
    6. Add the following code to the DrawPage event handler:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      'e.page parameter determines the page
      If e.Page Is c1OutPage1 Then
         e.Graphics.FillRectangle(Brushes.Gold, e.Bounds)
         e.Graphics.DrawString("I", c1OutBar1.Font, Brushes.Black, New PointF(e.Bounds.Right - 40, e.Bounds.Top + 2))
      ElseIf e.Page Is c1OutPage2 Then
         e.Graphics.FillRectangle(Brushes.Silver, e.Bounds)
         e.Graphics.DrawString("II", c1OutBar1.Font, Brushes.White, New PointF(e.Bounds.Right - 40, e.Bounds.Top + 2))
      ElseIf e.Page Is c1OutPage3 Then
         e.Graphics.FillRectangle(Brushes.Plum, e.Bounds)
         e.Graphics.DrawString("III", c1OutBar1.Font, Brushes.Yellow, New PointF(e.Bounds.Right - 40, e.Bounds.Top + 2))
      End If
      

      To write code in C#

      C#
      Copy Code
      \\e.page determines the page
      If (e.Page == c1OutPage1) 
      {
          e.Graphics.FillRectangle(Brushes.Gold, e.Bounds);
          e.Graphics.DrawString("I", c1OutBar1.Font, Brushes.Black, new PointF(e.Bounds.Right - 40, e.Bounds.Top + 2));
      }
      else if (e.Page == c1OutPage2) 
      {
          e.Graphics.FillRectangle(Brushes.Silver, e.Bounds);
          e.Graphics.DrawString("II", c1OutBar1.Font, Brushes.White, new PointF(e.Bounds.Right -40, e.Bounds.Top + 2));
      }
      else if (e.Page == c1OutPage3) 
      {
          e.Graphics.FillRectangle(Brushes.Plum, e.Bounds);
          e.Graphics.DrawString("III", c1OutBar1.Font, Brushes.Yellow, new PointF(e.Bounds.Right - 40, e.Bounds.Top + 2));
      }
      
    7. Press F5 to run the project and observe that the titles are customized. The final product appears as follows:
      Form
    See Also