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