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.
- 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
- 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
- Click the ellipsis appearing in the CalendarStorage property to set the following mappings and click OK.
- Click the ellipsis appearing in the PropertyStorage property to set the following mappings and click OK.
- Click the ellipsis appearing in the ResourceStorage property to set the following mappings and click OK.
- Click the ellipsis appearing in the TasksStorage property to set the following mappings and click OK.
-
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 |
- In the Resources property, add four resources through Resource Collection Editor. Name these resources as Resource 1, Resource 2 and so on.
- 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
- 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.