All docs
V20.1
20.2 (EAP/Beta)
20.1
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

GanttControl.DependencyMappings Property

Provides access to data source field names that specify dependencies between tasks (dependency type, time lag, predecessor, and successor).

Namespace: DevExpress.XtraGantt

Assembly: DevExpress.XtraGantt.v20.1.dll

Declaration

[XtraSerializableProperty(XtraSerializationVisibility.Content, XtraSerializationFlags.DefaultValue)]
public GanttDependencyMappings DependencyMappings { get; }
<XtraSerializableProperty(XtraSerializationVisibility.Content, XtraSerializationFlags.DefaultValue)>
Public ReadOnly Property DependencyMappings As GanttDependencyMappings

Property Value

Type Description
GanttDependencyMappings

An object that maps data source fields to task properties.

Remarks

The DataSource property allows you to bind the control to a data source. The KeyFieldName property specifies a task's unique identifier (key). See the TreeList.KeyFieldName property for more information.

The ParentFieldName property specifies a parent task's key. This field allows you to organize tasks in a tree. See the TreeList.ParentFieldName property for more information.

You can also use a task's key to specify the task's predecessor(s).

If you need finish-to-start dependencies only, use the PredecessorsFieldName property to specify the data field that contains predecessors' keys. The data should be of the System.Collections.IEnumerable type. The enumerator should return key values of the same type as the key field. In particular, you can use the following types:

  • IList — use this type to allow users to modify dependencies and save changes to the data source. The collection should not be read only.
  • String — the string should contain keys separated by space, comma, or semicolon (' ', ',' ';').

If you need finish-to-start and other dependency types, use the PredecessorFieldName and SuccessorFieldName properties and a separate data source assigned to the DependencySource property. See Task Dependencies for more information.

Examples

The code below shows how to specify tasks and dependencies.

using DevExpress.XtraGantt;

ganttControl1.TreeListMappings.KeyFieldName = "ID";
ganttControl1.TreeListMappings.ParentFieldName = "ParentID";
ganttControl1.ChartMappings.TextFieldName = "Text";
ganttControl1.ChartMappings.StartDateFieldName = "StartDate";
ganttControl1.ChartMappings.FinishDateFieldName = "FinishDate";
ganttControl1.DataSource = GetTasks();

ganttControl1.DependencyMappings.PredecessorFieldName = "PredecessorID";
ganttControl1.DependencyMappings.SuccessorFieldName = "SuccessorID";
ganttControl1.DependencyMappings.TypeFieldName = "DependencyType";
ganttControl1.DependencyMappings.LagFieldName = "TimeLag";
ganttControl1.DependencySource = GetDependencies();

DataTable GetTasks() {
    DataTable table = new DataTable();
    DataColumn id = new DataColumn("ID", typeof(int));
    DataColumn parentId = new DataColumn("ParentID", typeof(int));
    DataColumn text = new DataColumn("Text", typeof(string));
    DataColumn start = new DataColumn("StartDate", typeof(DateTime));
    DataColumn finish = new DataColumn("FinishDate", typeof(DateTime));
    table.Columns.AddRange(new DataColumn[] { id, parentId, text, start, finish });
    table.Rows.Add(new object[] { 1, 0, "Task 1", DateTime.Now, DateTime.Now.AddDays(1) });
    table.Rows.Add(new object[] { 2, 0, "Task 2", DateTime.Now.AddDays(1), DateTime.Now.AddDays(2) });
    table.Rows.Add(new object[] { 3, 0, "Task 3", DateTime.Now.AddDays(2), DateTime.Now.AddDays(3) });
    return table;
}

    DataTable GetDependencies() {
    DataTable table = new DataTable();
    DataColumn predecessor = new DataColumn("PredecessorID", typeof(int));
    DataColumn successor = new DataColumn("SuccessorID", typeof(int));
    DataColumn dependencyType = new DataColumn("DependencyType", typeof(DevExpress.XtraGantt.DependencyType));
    DataColumn lag = new DataColumn("TimeLag", typeof(TimeSpan));
    table.Columns.AddRange(new DataColumn[] { predecessor, successor, dependencyType, lag });
    table.Rows.Add(new object[] { 1, 2, DependencyType.StartToFinish, new TimeSpan(12, 0, 0) });
    table.Rows.Add(new object[] { 2, 3, DependencyType.StartToStart, null });
    return table;
}
See Also