目時(shí)間表內(nèi)的時(shí)間軸)
DevExpress WinForms的Gantt組件在v23.1中附帶了一個(gè)新的時(shí)間軸UI元素Gantt甘特圖控件本身允許您計(jì)劃/管理項(xiàng)目而時(shí)間軸顯示單個(gè)任務(wù)的開始和截止日期并提供項(xiàng)目進(jìn)度的鳥瞰圖。DevExpress WinForms擁有180組件和UI庫(kù)能為Windows Forms平臺(tái)創(chuàng)建具有影響力的業(yè)務(wù)解決方案。DevExpress WinForms能完美構(gòu)建流暢、美觀且易于使用的應(yīng)用程序無(wú)論是Office風(fēng)格的界面還是分析處理大批量的業(yè)務(wù)數(shù)據(jù)它都能輕松勝任DevExpress新舊版本幫助文檔下載可進(jìn)QQ qun獲取169725316Timeline時(shí)間軸UI時(shí)間軸可以顯示多個(gè)帶有任務(wù)/里程碑、今日指示器和日期范圍選擇器的時(shí)間軸條。時(shí)間軸的上下文菜單允許用戶添加/刪除時(shí)間軸條從時(shí)間軸中刪除任務(wù)/里程碑或快速導(dǎo)航到甘特圖樹和圖表中的任務(wù)。顯示時(shí)間軸Gantt甘特圖控件可以在頂部或底部顯示時(shí)間軸。using DevExpress.XtraGantt; // Displays a timeline at the top of the Gantt control. ganttControl1.OptionsTimeline.TimelinePosition TimelinePosition.Top;用戶體驗(yàn)最終用戶的選項(xiàng)包括添加/刪除任務(wù)和里程碑到/從時(shí)間軸添加/刪除時(shí)間軸選擇多個(gè)任務(wù)(單擊一個(gè)任務(wù)并按住Ctrl鍵選擇該任務(wù))跳轉(zhuǎn)到任務(wù)平移和縮放時(shí)間軸規(guī)模選擇時(shí)間范圍調(diào)整時(shí)間軸時(shí)間軸自定義設(shè)置(API)使用GanttControl.OptionsTimeline屬性來(lái)訪問(wèn)和自定義時(shí)間軸設(shè)置TimelinePosition — 指定時(shí)間軸的可見(jiàn)性和位置。AllowResize — 指定時(shí)間軸的高度是否可以由用戶或代碼修改。TimelineHeight — 指定時(shí)間軸高度(以像素為單位)。ShowTodayIndicator — 是否顯示今日指標(biāo)。MinUnit/MaxUnit — 指定最小/最大時(shí)間間隔。您可以根據(jù)特定條件修改單個(gè)任務(wù)的標(biāo)題/詳細(xì)信息/描述要應(yīng)用修改請(qǐng)?zhí)幚鞢ustomTimelineItemText事件甘特圖控件為時(shí)間軸中顯示的每個(gè)任務(wù)觸發(fā)此事件。我們還實(shí)現(xiàn)了Custom Draw APIs自定義繪制API方便您可以根據(jù)需要繪制時(shí)間軸條和任務(wù)這些API包括CustomDrawTimelineBarCustomDrawTimelineTask將時(shí)間軸綁定到數(shù)據(jù)使用以下屬性將數(shù)據(jù)源中的字段映射到任務(wù)屬性ChartMappings.TimelineCaption — 指定數(shù)據(jù)源中字段的名稱(帶有用于時(shí)間軸上的任務(wù)標(biāo)題的字符串值)。ChartMappings.VisibleInTimelineFieldName — 指定數(shù)據(jù)源中字段的名稱(使用布爾值指定要在時(shí)間軸上顯示哪些任務(wù))。public Form1() { InitializeComponent(); // Bind the Gantt control to a data source. ganttControl1.DataSource TaskData.InitData(); // Configures the Gantt controls 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 ListTaskData InitData() { return new ListTaskData() { 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) }, }; } }所見(jiàn)即所得打印和導(dǎo)出您可以打印/導(dǎo)出甘特圖及其時(shí)間軸支持的導(dǎo)出文件格式包括PDF, XLS, XLSX, MHT, CSV, HTML, RTF, DOCX, TXT(或作為圖像文件)。