Data binding refers to the process of binding a data provider to a data consumer in a synchronized manner. You can bind GanttView control to any .NET data source requiring little code and display your project related attributes. GanttView supports data binding with various ADO.NET objects such as DataTable, DataView and DataSet.
The instructions given below explain step-by-step procedure for binding the GanttView control to a data source. This example uses a sample database file, Nwind.mdb, as the data source for binding.
Complete the steps given below to bind the GanttView control to a data source.
XAML |
Copy Code
|
---|---|
<c1:C1GanttView x:Name="gv" Margin="0,37,0,0"> |
The Nwind.mdb database file is by default kept in the installed folder at the following location. C:\Users\...\Documents\ComponentOne Samples\Common\Nwind.mdb |
Complete the following steps to store data in your dataset and retrieve the same to display various project related attributes in GanttView.
Imports C1.GanttView Imports DataBinding.C1NWindDataSetTableAdapters
using C1.GanttView; using DataBinding.C1NWindDataSetTableAdapters;
Private c1NwindDataSet1 As New C1NWindDataSet() Private tasksTableAdapter As New TasksTableAdapter() Private calendarsTableAdapter As New CalendarsTableAdapter() Private resourcesTableAdapter As New ResourcesTableAdapter() Private propertiesTableAdapter As New PropertiesTableAdapter()
private C1NWindDataSet c1NwindDataSet1 = new C1NWindDataSet(); private TasksTableAdapter tasksTableAdapter = new TasksTableAdapter(); private CalendarsTableAdapter calendarsTableAdapter = new CalendarsTableAdapter(); private ResourcesTableAdapter resourcesTableAdapter = new ResourcesTableAdapter(); private PropertiesTableAdapter propertiesTableAdapter = new PropertiesTableAdapter();
Me.tasksTableAdapter.Fill(c1NwindDataSet1.Tasks) Me.resourcesTableAdapter.Fill(c1NwindDataSet1.Resources) Me.propertiesTableAdapter.Fill(c1NwindDataSet1.Properties) Me.calendarsTableAdapter.Fill(c1NwindDataSet1.Calendars)
this.tasksTableAdapter.Fill(c1NwindDataSet1.Tasks); this.resourcesTableAdapter.Fill(c1NwindDataSet1.Resources); this.propertiesTableAdapter.Fill(c1NwindDataSet1.Properties); this.calendarsTableAdapter.Fill(c1NwindDataSet1.Calendars);
Private Sub gv_Loaded(sender As Object, e As RoutedEventArgs) Dim storage As C1GanttViewStorage = gv.DataStorage storage.CalendarStorage.Mappings.CalendarID.MappingName = "CalendarID" storage.CalendarStorage.Mappings.Data.MappingName = "Data" storage.CalendarStorage.Mappings.IdMapping.MappingName = "Id" storage.CalendarStorage.Mappings.Name.MappingName = "Name" storage.CalendarStorage.DataMember = "Calendars" storage.CalendarStorage.DataSource = Me.c1NwindDataSet1 storage.PropertyStorage.Key.MappingName = "Key" storage.PropertyStorage.Value.MappingName = "Value" storage.PropertyStorage.DataMember = "Properties" storage.PropertyStorage.DataSource = Me.c1NwindDataSet1 storage.ResourceStorage.Mappings.Cost.MappingName = "Cost" storage.ResourceStorage.Mappings.IdMapping.MappingName = "Id" storage.ResourceStorage.Mappings.Name.MappingName = "Name" storage.ResourceStorage.Mappings.Notes.MappingName = "Notes" storage.ResourceStorage.Mappings.ResourceID.MappingName = "ResourceID" storage.ResourceStorage.Mappings.ResourceType.MappingName = "ResourceType" storage.ResourceStorage.Mappings.UnitOfMeasure.MappingName = "UnitOfMeasure" storage.ResourceStorage.DataMember = "Resources" storage.ResourceStorage.DataSource = Me.c1NwindDataSet1 storage.TasksStorage.Mappings.CalendarID.MappingName = "CalendarID" storage.TasksStorage.Mappings.ConstraintDate.MappingName = "ConstraintDate" storage.TasksStorage.Mappings.ConstraintType.MappingName = "ConstraintType" storage.TasksStorage.Mappings.CustomFields.MappingName = "CustomFields" storage.TasksStorage.Mappings.Deadline.MappingName = "Deadline" storage.TasksStorage.Mappings.Duration.MappingName = "Duration" storage.TasksStorage.Mappings.DurationUnits.MappingName = "DurationUnits" storage.TasksStorage.Mappings.Finish.MappingName = "Finish" storage.TasksStorage.Mappings.HideBar.MappingName = "HideBar" storage.TasksStorage.Mappings.IdMapping.MappingName = "Id" storage.TasksStorage.Mappings.Initialized.MappingName = "Initialized" storage.TasksStorage.Mappings.Mode.MappingName = "Mode" storage.TasksStorage.Mappings.Name.MappingName = "Name" storage.TasksStorage.Mappings.NextID.MappingName = "NextID" storage.TasksStorage.Mappings.Notes.MappingName = "Notes" storage.TasksStorage.Mappings.Parts.MappingName = "Parts" storage.TasksStorage.Mappings.PercentComplete.MappingName = "PercentComplete" storage.TasksStorage.Mappings.Predecessors.MappingName = "Predecessors" storage.TasksStorage.Mappings.Resources.MappingName = "Resources" storage.TasksStorage.Mappings.Start.MappingName = "Start" storage.TasksStorage.Mappings.TaskID.MappingName = "TaskID" storage.TasksStorage.DataMember = "Tasks" storage.TasksStorage.DataSource = Me.c1NwindDataSet1 End Sub
private void gv_Loaded(object sender, RoutedEventArgs e) { C1GanttViewStorage storage = gv.DataStorage; storage.CalendarStorage.Mappings.CalendarID.MappingName = "CalendarID"; storage.CalendarStorage.Mappings.CalendarID.MappingName = "CalendarID"; storage.CalendarStorage.Mappings.Data.MappingName = "Data"; storage.CalendarStorage.Mappings.IdMapping.MappingName = "Id"; storage.CalendarStorage.Mappings.Name.MappingName = "Name"; storage.CalendarStorage.DataMember = "Calendars"; storage.CalendarStorage.DataSource = this.c1NwindDataSet1; storage.PropertyStorage.Key.MappingName = "Key"; storage.PropertyStorage.Value.MappingName = "Value"; storage.PropertyStorage.DataMember = "Properties"; storage.PropertyStorage.DataSource = this.c1NwindDataSet1; storage.ResourceStorage.Mappings.Cost.MappingName = "Cost"; storage.ResourceStorage.Mappings.IdMapping.MappingName = "Id"; storage.ResourceStorage.Mappings.Name.MappingName = "Name"; storage.ResourceStorage.Mappings.Notes.MappingName = "Notes"; storage.ResourceStorage.Mappings.ResourceID.MappingName = "ResourceID"; storage.ResourceStorage.Mappings.ResourceType.MappingName = "ResourceType"; storage.ResourceStorage.Mappings.UnitOfMeasure.MappingName = "UnitOfMeasure"; storage.ResourceStorage.DataMember = "Resources"; storage.ResourceStorage.DataSource = this.c1NwindDataSet1; storage.TasksStorage.Mappings.CalendarID.MappingName = "CalendarID"; storage.TasksStorage.Mappings.ConstraintDate.MappingName = "ConstraintDate"; storage.TasksStorage.Mappings.ConstraintType.MappingName = "ConstraintType"; storage.TasksStorage.Mappings.CustomFields.MappingName = "CustomFields"; storage.TasksStorage.Mappings.Deadline.MappingName = "Deadline"; storage.TasksStorage.Mappings.Duration.MappingName = "Duration"; storage.TasksStorage.Mappings.DurationUnits.MappingName = "DurationUnits"; storage.TasksStorage.Mappings.Finish.MappingName = "Finish"; storage.TasksStorage.Mappings.HideBar.MappingName = "HideBar"; storage.TasksStorage.Mappings.IdMapping.MappingName = "Id"; storage.TasksStorage.Mappings.Initialized.MappingName = "Initialized"; storage.TasksStorage.Mappings.Mode.MappingName = "Mode"; storage.TasksStorage.Mappings.Name.MappingName = "Name"; storage.TasksStorage.Mappings.NextID.MappingName = "NextID"; storage.TasksStorage.Mappings.Notes.MappingName = "Notes"; storage.TasksStorage.Mappings.Parts.MappingName = "Parts"; storage.TasksStorage.Mappings.PercentComplete.MappingName = "PercentComplete"; storage.TasksStorage.Mappings.Predecessors.MappingName = "Predecessors"; storage.TasksStorage.Mappings.Resources.MappingName = "Resources"; storage.TasksStorage.Mappings.Start.MappingName = "Start"; storage.TasksStorage.Mappings.TaskID.MappingName = "TaskID"; storage.TasksStorage.DataMember = "Tasks"; storage.TasksStorage.DataSource = this.c1NwindDataSet1; }