翻譯|使用教程|編輯:黃竹雯|2018-10-25 17:03:22.000|閱讀 403 次
概述:本文將告訴您使用VARCHART XGantt時(shí),為分組甘特圖添加舒適排序選項(xiàng)的三個(gè)步驟。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
大多數(shù)人習(xí)慣于使用舒適的排序選項(xiàng),例如在Windows資源管理器中:?jiǎn)螕袅械谋眍^將按升序或降序?qū)ξ募M(jìn)行排序,這由表中向上或向下指示的箭頭指示頭。
如果您也可以在VARCHART XGantt中使用此功能,那不是很好嗎?在本文中,我將向您展示如何通過三個(gè)簡(jiǎn)單的步驟完成這項(xiàng)工作,并且只需很少的一部分編程。
下圖顯示了Windows資源管理器中按“升級(jí)修改日期”列按升序排序的文件,該文件由向上指向的小箭頭指示:
這個(gè)小箭頭可以很容易地添加到您的甘特圖 - 只需按照下面描述的三個(gè)步驟。
您需要兩個(gè)用于顯示箭頭的圖形文件,以下稱為arrow-down.png和arrow-up.png, 它們必須作為資源 添加到Visual Studio解決方案中。
在XGantt表格式StandardListCaption中,您必須勾選所有字段的文本/圖形組合復(fù)選框。
執(zhí)行上述步驟后,您只需向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; }
如果一切都按計(jì)劃進(jìn)行,甘特圖中的表格標(biāo)題現(xiàn)在應(yīng)該顯示排序箭頭,如下圖所示:
現(xiàn)在您可以去試試看了。如果到目前為止您還沒有使用VARCHART XGantt,歡迎隨時(shí)下載最新試用版。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn