原創|其它|編輯:郝浩|2012-12-17 14:25:51.000|閱讀 1346 次
概述:本文介紹運用DXperience 12.2創建甘特圖視圖的日程管理應用程序。提供DXperience12.2更新信息和免費下載。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
最新發布的DXperience 12.2提供了更加完整的用戶界面控件。在上一篇中,我們創建了一個Win8界面風格的日程管理應用,今天我將為大家展示日程管理(Schedule)控件的甘特圖視圖(Gantt View)功能。
Gantt View有一個支持分層資源的功能。為此,DXperience 12.2將Resources Tree 控件用分層的形式顯示日程管理資源。在Visual Studio中打開設計器,新建Form1,選擇XtraNavBar,并在工具欄中將它替換為ResourcesTree。
如圖所示,點擊Resources Tree的智能標簽,就會看到它已經自動綁定到Scheduler Control表單中:
Resources Tree建在Tree List頂端時,支持多列。要定義這個屬性,點擊Smart Tag并運行設計器。
接下來需要一個 XtraTreeList集合的引用,右鍵單擊Solution Explorer的項目然后點擊Add Reference。
單擊Start查看效果,如圖所示,資源在左邊以樹形結構顯示:
接下來在每個資源下創建一些命令:
然后右鍵單擊其中一個:
我們看到,Create Dependency選項是灰色的。要啟用它,我們需要傳遞命令ID,最簡單的方式之一是從數據適配器中獲取DB ID。由于我們的主關鍵字用的是 identity (auto-inc)列,所以可以用以下代碼:
private void Form1_Load(object sender, EventArgs e) { ... // Get the auto-inc value from SQL Server appointmentsTableAdapter.Adapter.RowUpdated += appointmentsTableAdapter_RowUpdated; } private int insertedId; private void appointmentsTableAdapter_RowUpdated(object sender, SqlRowUpdatedEventArgs e) { if (e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert) { // Store the inserted ID so we can update the underlying appointment // in schedulerStorage_AppointmentsInserted insertedId = (int)e.Row["UniqueId"]; } } Now assign the new id to the appointment object: private void schedulerStorage_AppointmentsInserted(object sender, PersistentObjectsEventArgs e) { CommitTask(); // Set the auto-inc value from SQL Server within the XtraScheduler appointment // this is needed, for instance, to create dependencies for newly inserted appointments // othrwise the option will be disabled schedulerStorage.SetAppointmentId((Appointment)e.Objects[0], insertedId); }
在做了上述這些操作后,我們就可以創建新命令的依賴項了:
將命令和Resource綁定到數據源,現在我們需要綁定依賴項數據源。在設計器的Form1.cs,打開schedulerStorage的智能標簽,從我們的數據集中對它進行分配:
驗證字段映射:
最后確保依賴項已經保存到數據庫中,為此,我們將處理以下事件:AppointmentDependenciesChanged, AppointmentDependentciesDeleted 和 AppointmentDependenciesInserted。
以上三個事件都可以用下面的代碼進行處理:
private void schedulerStorage_AppointmentDependenciesChanged(object sender, PersistentObjectsEventArgs e) { CommitTaskDependency(); } private void schedulerStorage_AppointmentDependenciesDeleted(object sender, PersistentObjectsEventArgs e) { CommitTaskDependency(); } private void schedulerStorage_AppointmentDependenciesInserted(object sender, PersistentObjectsEventArgs e) { CommitTaskDependency(); } private void CommitTaskDependency() { taskDependenciesTableAdapter.Update(dXProjectManagerDataSet); }
最后,一個甘特圖視圖的日程管理應用就建好了:
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件