ComponentOne GanttView for WinForms
Step 3: Binding GanttView to the Data Source
Data Binding: GanttView for WinForms > Step 3: Binding GanttView to the Data Source

In this step, you begin by setting selected properties of C1GanttView class at design-time. These settings are to bind the GanttView control to the added data source, and enhance the visual appearance of the control.

  1. In the form, select the GanttView control and navigate to the Properties window to make the following settings under DataStorage component.
    • CalendarStorage:
      • DataMember - Calendars
      • DataSource - c1NWindDataSet.
    • PropertyStorage:
      • DataMember - Properties
      • DataSource - c1NWindDataSet
      • Key MappingName - Key ; Value MappingName - Value.
    • ResourceStorage:
      • DataMember - Resources
      • DataSource - c1NWindDataSet
    • TaskStorage:
      • DataMember - Tasks
      • DataSource - c1NWindDataSet
  2. In DefaultWorkingTimes component in Properties window, make the following settings.
    • Interval_1:
      • Empty - False
      • From - 9:00 AM.
      • To - 1:00 PM
    • Interval_2:
      • Empty - False
      • From - 2:00 PM.
      • To - 6:00 PM
  3. Click the ellipsis appearing in the CalendarStorage property to set the following mappings and click OK.

  4. Click the ellipsis appearing in the PropertyStorage property to set the following mappings and click OK.

  5. Click the ellipsis appearing in the ResourceStorage property to set the following mappings and click OK.

  6. Click the ellipsis appearing in the TasksStorage property to set the following mappings and click OK.

  7. Refer to the following table to see all the mappings required for TasksStorage property.

    Id Mapping Id
    Initialized Initialized
    Task ID TaskID
    Next task ID NexID
    Outline parent ID OutlineParentID
    Summary Summary
    Name Name
    Start Start
    Finish Finish
    Duration Duration
    Mode Mode
    Calendar ID CalendarID
    Duration units DurationUnits
    Percent complete PercentComplete
    Deadline Deadline
    Constraint type ConstraintType
    Hide bar HideBar
    Predecessors Predecessors
    Resources Resources
    Custom fields CustomFields
    Notes Notes
  8. In the Resources property, add four resources through Resource Collection Editor. Name these resources as Resource 1, Resource 2 and so on.
  9. Locate the TimeScale component in Properties window to make the following timescale settings.
    • MiddleTier:
      • Units - Weeks
      • Count - 1
      • Format - nnnn d
      • Visible - True
    • BottomTier:
      • Units - Days
      • Count - 1
      • Format - w
      • Align - Center
      • Visible - True
      • UseFiscalYear - True
  10. Press F5 to run the application. The output window displays the GanttView control with data fetched from the added data source. The GanttView control appears similar to the following image.

 With this, you have completed data binding in GanttView for WinForms.