Back to Devexpress

GanttChartMappings.VisibleInTimelineFieldName Property

windowsforms-devexpress-dot-xtragantt-dot-ganttchartmappings-fb0fad2e.md

latest6.1 KB
Original Source

GanttChartMappings.VisibleInTimelineFieldName Property

Gets or sets the name of a field in a data source, with Boolean values that specify which tasks to display on the timeline.

Namespace : DevExpress.XtraGantt

Assembly : DevExpress.XtraGantt.v25.2.dll

NuGet Package : DevExpress.Win.Gantt

Declaration

csharp
[DefaultValue("VisibleInTimeline")]
[DXCategory("Mappings")]
[XtraSerializableProperty]
public string VisibleInTimelineFieldName { get; set; }
vb
<DXCategory("Mappings")>
<DefaultValue("VisibleInTimeline")>
<XtraSerializableProperty>
Public Property VisibleInTimelineFieldName As String

Property Value

TypeDefaultDescription
String"VisibleInTimeline"

The name of a field in a data source, with Boolean values that specify which tasks to display on the timeline.

|

Remarks

The following example demonstrates how to specify timeline mappings:

csharp
public Form1() {
    InitializeComponent();
    // Bind the Gantt control to a data source.
    ganttControl1.DataSource = TaskData.InitData();
    // Configures the Gantt control's mappings.
    ganttControl1.TreeListMappings.KeyFieldName = "Id";
    ganttControl1.TreeListMappings.ParentFieldName = "ParentId";
    ganttControl1.ChartMappings.StartDateFieldName = "StartDate";
    ganttControl1.ChartMappings.FinishDateFieldName = "EndDate";
    ganttControl1.ChartMappings.TimelineCaption = "TimelineCaption";
    // Maps the Gantt control to a field in a data source with Boolean values that
    // specify which tasks to display on the timeline when the application starts.
    ganttControl1.ChartMappings.VisibleInTimelineFieldName = "ShowInTimeline";
    // Displays the timeline at the top of the Gantt control.
    ganttControl1.OptionsTimeline.TimelinePosition = DevExpress.XtraGantt.TimelinePosition.Top;
}

public class TaskData {
    public TaskData(int id) {
        this.id = id;
    }
    int id;
    public int Id {
        get { return id; }
    }
    public string TimelineCaption {
        get { return string.Format("Timeline Caption: {0}", Name); }
    }
    public bool ShowInTimeline { get; set; } = false;
    public int ParentId { get; set; }
    public string Name { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }
    public static List<TaskData> InitData() {
        return new List<TaskData>() {
            new TaskData(0){ Name = "Task A", ParentId = 0, StartDate = new DateTime(2023, 3, 1), EndDate = new DateTime(2024, 3, 31) },
            new TaskData(1){ Name = "Task B", ParentId = 0, StartDate = new DateTime(2023, 3, 1), EndDate = new DateTime(2023, 7, 1), ShowInTimeline = true },
            new TaskData(2){ Name = "Task C", ParentId = 0, StartDate = new DateTime(2023, 7, 1), EndDate = new DateTime(2023, 11, 1) },
            new TaskData(3){ Name = "Task D", ParentId = 0, StartDate = new DateTime(2023, 11, 1), EndDate = new DateTime(2024, 3, 31) },
        };
    }
}
vb
Public Sub New()
    InitializeComponent()
    ' Binds the Gantt control to a data source.
    ganttControl1.DataSource = TaskData.InitData()
    ' Configures the Gantt control's mappings.
    ganttControl1.TreeListMappings.KeyFieldName = "Id"
    ganttControl1.TreeListMappings.ParentFieldName = "ParentId"
    ganttControl1.ChartMappings.StartDateFieldName = "StartDate"
    ganttControl1.ChartMappings.FinishDateFieldName = "EndDate"
    ganttControl1.ChartMappings.TimelineCaption = "TimelineCaption"
    ' Maps the Gantt control to a field in a data source with Boolean values that
    ' specify which tasks to display on the timeline when the application starts.
    ganttControl1.ChartMappings.VisibleInTimelineFieldName = "ShowInTimeline"
    ' Displays the timeline at the top of the Gantt control.
    ganttControl1.OptionsTimeline.TimelinePosition = DevExpress.XtraGantt.TimelinePosition.Top
End Sub

Public Class TaskData
    Public Sub New(ByVal id As Integer)
        Me.id_Renamed = id
    End Sub
'INSTANT VB NOTE: The variable id was renamed since Visual Basic does not allow variables and other class members to have the same name:
    Private id_Renamed As Integer
    Public ReadOnly Property Id() As Integer
        Get
            Return id_Renamed
        End Get
    End Property
    Public ReadOnly Property TimelineCaption() As String
        Get
            Return String.Format("Timeline Caption: {0}", Name)
        End Get
    End Property
    Public Property ShowInTimeline() As Boolean
    = False
    public Integer ParentId {get;set;}
    public String Name {get;set;}
    public DateTime StartDate {get;set;}
    public DateTime EndDate {get;set;}
    public static List(Of TaskData) InitData()
        Return New List(Of TaskData)() From {
            New TaskData(0) With {.Name = "Task A", .ParentId = 0, .StartDate = New Date(2023, 3, 1), .EndDate = New Date(2024, 3, 31)},
            New TaskData(1) With {.Name = "Task B", .ParentId = 0, .StartDate = New Date(2023, 3, 1), .EndDate = New Date(2023, 7, 1), .ShowInTimeline = True},
            New TaskData(2) With {.Name = "Task C", .ParentId = 0, .StartDate = New Date(2023, 7, 1), .EndDate = New Date(2023, 11, 1)},
            New TaskData(3) With {.Name = "Task D", .ParentId = 0, .StartDate = New Date(2023, 11, 1), .EndDate = New Date(2024, 3, 31)}
        }
End Class

See Also

ChartMappings

GanttChartMappings Class

GanttChartMappings Members

DevExpress.XtraGantt Namespace