原創|使用教程|編輯:龔雪|2021-03-30 11:01:51.310|閱讀 361 次
概述:本文將為大家介紹DevExpress WinForms表單和用戶控件當中的等待表單,初始屏幕管理器允許您創建一個等待表單(WaitForm) - 一種旨在識別皮膚的表單,用于指示耗時的操作。歡迎下載最新版DevExpress體驗!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
初始屏幕管理器允許您創建一個等待表單(WaitForm) - 一種旨在識別皮膚的表單,用于指示耗時的操作。
主要功能包括:
將 組件拖放到窗體上,右鍵單擊Visual Studio托盤中的組件,然后選擇Add Wait Form。
SplashScreenManager將新的WaitForm添加到您的項目。
要在設計時查看和自定義等待表單,請在Solution Explorer中雙擊WaitForm1.cs(WaitForm1.vb)文件。
使用屬性網格更改內置ProgressPanel的顯示設置,此面板顯示動畫進度指示器和標簽。
注意:如果需要使用自定義類擴展WaitForm1.cs/.vb文件,請確保封裝Wait Form的類在這些文件中排在第一位。
等待表單不會在主表單啟動時自動顯示。 您可以使用以下方法顯示和關閉等待表單,具體取決于等待表單是否處于激活狀態(已分配給 屬性)。
要顯示/關閉等待表單,請使用非靜態的和方法。
C#
splashScreenManager1.ShowWaitForm(); //... splashScreenManager1.CloseWaitForm();
VB.NET
splashScreenManager1.ShowWaitForm() '... splashScreenManager1.CloseWaitForm()
要顯示/關閉等待表單,請使用靜態和方法。 特定的方法重載允許您指定淡入淡出效果和等待表單位置。
C#
SplashScreenManager.ShowForm(typeof(WaitForm1)); //... SplashScreenManager.CloseForm();
VB.NET
SplashScreenManager.ShowForm(GetType(WaitForm1)) '... SplashScreenManager.CloseForm()
與其他初始屏幕一樣,等待表單也顯示在單獨的線程中。
使用以下方法從主線程動態更新顯示等待表單的標題和描述:
您還可以使用方法與當前的等待表單進行交互(例如,更新其內容)。 要處理此方法發送的命令,請重寫方法。
顯示多個等待表單
如果您的應用程序一次只顯示一個等待表單,則可以使用單個SplashScreenManager組件。
若要同時顯示多個等待表單,請使用多個SplashScreenManager組件。
MDI應用
在MDI應用程序中,不要顯示Control.CreateHandle方法調用的事件或方法的等待表單 - HandleCreated,Load,MdiChildActivate,OnHandleCreated重載等,否則您的應用程序可能會凍結。
而是,使用以下方法:
C#
//Incorrect - the app may freeze private void MdiParent_MdiChildActivate(object sender, EventArgs e) { //... splashScreenManager1.ShowWaitForm(); splashScreenManager1.SetWaitFormCaption("Please wait"); splashScreenManager1.SetWaitFormDescription(description); //... splashScreenManager1.CloseWaitForm(); } //Correct private void MdiParent_MdiChildActivate(object sender, EventArgs e) { BeginInvoke(new Action(() => { //... splashScreenManager1.ShowWaitForm(); splashScreenManager1.SetWaitFormCaption("Please wait"); splashScreenManager1.SetWaitFormDescription(description); //... splashScreenManager1.CloseWaitForm(); })); }
VB.NET
'Incorrect - the app may crash Private Sub MdiParent_MdiChildActivate(ByVal sender As Object, ByVal e As EventArgs) '... splashScreenManager1.ShowWaitForm() splashScreenManager1.SetWaitFormCaption("Please wait") splashScreenManager1.SetWaitFormDescription(description) '... splashScreenManager1.CloseWaitForm() End Sub 'Correct Private Sub MdiParent_MdiChildActivate(ByVal sender As Object, ByVal e As EventArgs) BeginInvoke(New Action(Sub() '... splashScreenManager1.ShowWaitForm() splashScreenManager1.SetWaitFormCaption("Please wait") splashScreenManager1.SetWaitFormDescription(description) '... splashScreenManager1.CloseWaitForm() End Sub)) End Sub
DevExpress技術交流群3:700924826 歡迎一起進群討論
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都網