ComponentOne EventsCalendar for ASP.NET Web Forms
Working with EventsCalendar for ASP.NET Web Forms / Views / Customizing the View
In This Topic
    Customizing the View
    In This Topic

    EventsCalendar shows Day, Week, Month and List views as default views. You can easily change the events calendar to show custom views by adding new views(such as two weeks or two months) having ViewType set to "Custom". You can customize the data view of the C1EventsCalendar control at design time using the Properties window, in Source view, and in Code.

    Complete the following steps to add four custom views, 2 Days, 2 Weeks, 2 Months and 2 Years, and to set the active ViewType to 2 Months.

    In Source View

    Switch to Source view and modify the <cc1:C1EventsCalendar> tags.

                     
    <cC1:C1EventsCalendar runat="server" ID="C1EventsCalendar1" Width="60%" Height="475px">
       <Views>
            <cC1:View Type="Day">
            </cC1:View>
            <cC1:View Type="Custom" Name="2 Days" Unit="Day" Count="2">
        </cC1:View>
            <cC1:View Type="Custom" Name="2 Weeks" Unit="Week" Count="2">
            </cC1:View>
            <cC1:View Type="Custom" Name="2 Months" Unit="Month" Count="2" IsActive ="true">
            </cC1:View>
            <cC1:View Type="Custom" Name="2 Years" Unit="Year" Count="2">
        </cC1:View>
      </Views>
    </cC1:C1EventsCalendar>
            
    

    In the Properties Window

    1. Right click the C1EventsCalendar control to open its Property window.
    2. Navigate to the Visual Studio Properties window and locate the Views property.
    3. Click the ellipsis button (...) next to Views property to open the View Collection Editor.
    4. Click the Add button five times to add five new members in the header bar.
    5. Set the Type of Member 1, 2, 3 and 4 to Custom. By default it is set to Day.
    6. Set the Name property for each member you added as follows:
      • Member 1: 2 Days
      • Member 2: 2 Weeks
      • Member 3: 2 Months
      • Member 4: 2 Years
    7. Set the Count property to 2 for all four custom members. By default it is set to 1.
    8. Set IsActive to True for member 2 Months.

    9. Click OK and press F5 to run the project.

    In Code

    Visual Basic
    Copy Code
    C1EventsCalendar1.Views[2].IsActive = true
    


    C#
    Copy Code
    C1EventsCalendar1.Views[2].IsActive = true;
    

    What You've Accomplished

    When you run the project, EventsCalendar appears as shown in the image below.