翻譯|使用教程|編輯:黃竹雯|2019-01-14 11:17:17.000|閱讀 316 次
概述:本文主要介紹提高甘特圖分組排序舒適度的三個步驟
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
VARCHART XGantt是一款功能強大的甘特圖控件,其模塊化的設計讓您可以創建滿足需要的應用程序。XGantt可用于.NET,ActiveX和ASP.NET應用程序,可以快速、簡單地集成到您的應用程序中,幫助您識別性能瓶頸、避免延遲以及高效利用資源,使復雜數據變得更加容易理解。
點擊下方鏈接下載VARCHART XGantt最新資源免費試用:
大多數人習慣于使用舒適的排序選項,例如在Windows資源管理器中單擊表中向上或向下指示的剪頭,列的表頭將按升序或降序對文件進行排序。本文主要向您展示在很少編程工作下為甘特圖分組添加舒適排序選項的三個步驟,有任何建議或提示請在下方評論留言,方便大家學習交流。
下圖顯示了Windows資源管理器中Date modified列按升序排序的文件,該文件由向上指向的小箭頭指示:
按下文提示的步驟可以很容易地在您的甘特圖中實現舒適排列:
您需要兩個用于顯示箭頭的圖形文件,以下稱為arrow-down.png和arrow-up.png, 它們必須作為Resources添加到Visual Studio解決方案中。
在XGantt表格StandardListCaption中,勾選所有字段的Text/Graphics combiined復選框。
執行上述步驟后,向Gantt控件添加一些代碼:
int _sortedByColumn = 3; private void Form1_Load(object sender, EventArgs e) { //Make the resources available for XGantt: //In the following 2 lines the namespace has be be adjusted as necessary. vcGantt1.SetImageResource("*ArrowDown",Default_Configuration.Properties.Resources.arrow_down); vcGantt1.SetImageResource("*ArrowUp", Default_Configuration.Properties.Resources.arrow_up); //Set the arrow in the table column by which your nodes are initially sorted: VcTable activeTable = vcGantt1.TableCollection.Active; VcTableFormat standardListCaptionTF = activeTable.TableFormatCollection.FormatByName("StandardListCaption"); //Select the table format field by which your nodes are initially sorted: VcTableFormatField tff = standardListCaptionTF.get_FormatField(2); tff.GraphicsFileName = "*ArrowUp"; //... } private void vcGantt1_VcTableCaptionLeftClicking(object sender, VcTableClickingEventArgs e) { VcNodeLevelLayout nodeLevelLayout = vcGantt1.NodeLevelLayout; VcTableFormat standardListCaptionTF = e.Table.TableFormatCollection.FormatByName("StandardListCaption"); VcTableFormatField tff = standardListCaptionTF.get_FormatField((short)(e.ColumnNumber - 1)); if (e.ColumnNumber == _sortedByColumn) //Clicked again on the same column: Just reverse the sort order! { if (nodeLevelLayout.get_SortOrder(0) == VcNodeSortingOrder.vcAscending) { nodeLevelLayout.set_SortOrder(0, VcNodeSortingOrder.vcDescending); tff.GraphicsFileName = "*ArrowDown"; } else { nodeLevelLayout.set_SortOrder(0, VcNodeSortingOrder.vcAscending); tff.GraphicsFileName = "*ArrowUp"; } } else //Clicked on another column: Sort by this column. Sort order: ascending { nodeLevelLayout.set_SortDataFieldIndex(0, tff.Index); nodeLevelLayout.set_SortOrder(0, VcNodeSortingOrder.vcAscending); tff.GraphicsFileName = "*ArrowUp"; tff = standardListCaptionTF.get_FormatField((short)(_sortedByColumn - 1)); tff.GraphicsFileName = string.Empty; } vcGantt1.SortNodes(); _sortedByColumn = e.ColumnNumber; }
如果一切都按計劃進行,甘特圖中的表格標題現在應該顯示排序箭頭,如下圖所示:
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn