翻譯|行業資訊|編輯:龔雪|2023-08-09 10:48:34.100|閱讀 119 次
概述:本文將為大家介紹界面控件DevExpress WinForms的Gantt組件,在v23.1中附帶了一個新的時間軸UI元素。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
DevExpress WinForms的Gantt組件在v23.1中附帶了一個新的時間軸UI元素,Gantt(甘特圖)控件本身允許您計劃/管理項目,而時間軸顯示單個任務的開始和截止日期,并提供項目進度的鳥瞰圖。
DevExpress WinForms 擁有180+組件和UI庫,能為Windows Forms平臺創建具有影響力的業務解決方案。DevExpress WinForms能完美構建流暢、美觀且易于使用的應用程序,無論是Office風格的界面,還是分析處理大批量的業務數據,它都能輕松勝任!
DevExpress技術交流群8:523159565 歡迎一起進群討論
時間軸可以顯示多個帶有任務/里程碑、今日指示器和日期范圍選擇器的時間軸條。
時間軸的上下文菜單允許用戶添加/刪除時間軸條,從時間軸中刪除任務/里程碑,或快速導航到甘特圖樹和圖表中的任務。
Gantt(甘特圖)控件可以在頂部或底部顯示時間軸。
using DevExpress.XtraGantt; // Displays a timeline at the top of the Gantt control. ganttControl1.OptionsTimeline.TimelinePosition = TimelinePosition.Top;
最終用戶的選項包括:
使用GanttControl.OptionsTimeline屬性來訪問和自定義時間軸設置:
您可以根據特定條件修改單個任務的標題/詳細信息/描述,要應用修改,請處理CustomTimelineItemText事件,甘特圖控件為時間軸中顯示的每個任務觸發此事件。
我們還實現了Custom Draw APIs(自定義繪制API),方便您可以根據需要繪制時間軸條和任務,這些API包括:
使用以下屬性將數據源中的字段映射到任務屬性:
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"; } 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) }, }; } }
您可以打印/導出甘特圖及其時間軸,支持的導出文件格式包括:PDF, XLS, XLSX, MHT, CSV, HTML, RTF, DOCX, TXT(或作為圖像文件)。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都網