C# WinForm 弹出模式窗口操作滚动条
生活随笔
收集整理的這篇文章主要介紹了
C# WinForm 弹出模式窗口操作滚动条
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
彈出的模式窗體
public partial class frmProcessBar : Form {public frmProcessBar(){InitializeComponent();}public bool Increase(int runTime){if (runTime > 0){int tempTime = Convert.ToInt32(prcBar.Value);if (tempTime % 10 == 0){this.labTimer.Text = (Convert.ToInt32(this.labTimer.Text) + runTime).ToString();}if (prcBar.Value + runTime < prcBar.Maximum){prcBar.Value += runTime;return true;}else{prcBar.Value = prcBar.Maximum;this.Close();return false;}}return false;} }測試用例
public delegate string AsyncMethodCaller(); public delegate void AsyncShowMethod(); private frmProcessBar myProcessBar = null; private delegate bool IncreaseHandle(int runTime); private IncreaseHandle myIncrease = null;private void ShowProcessBar() {myProcessBar = new frmProcessBar();myIncrease = new IncreaseHandle(myProcessBar.Increase);myProcessBar.StartPosition = FormStartPosition.CenterParent;myProcessBar.ShowDialog();myProcessBar = null; }string result = string.Empty;//接收返回的結果 AsyncMethodCaller callerRun = new AsyncMethodCaller(disPlay.Show); //耗時執行的方法 IAsyncResult synresult = callerRun.BeginInvoke(null, null); this.BeginInvoke(new AsyncShowMethod(ShowProcessBar)); //啟動彈出窗體 while (synresult.IsCompleted == false) {this.BeginInvoke(this.myIncrease, new object[] { 1, 1 });Thread.Sleep(100); } this.BeginInvoke(this.myIncrease, new object[] { 100, 1 }); result = callerRun.EndInvoke(synresult); // 返回執行的結果?
?
轉載于:https://www.cnblogs.com/rinack/archive/2012/09/29/2708099.html
總結
以上是生活随笔為你收集整理的C# WinForm 弹出模式窗口操作滚动条的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: LeetCode Online Judg
- 下一篇: jQuery中终止Ajax请求