我有一个表单,需要几秒钟才能最终显示。 此表单通过以下方式调用:
using (ResultsForm frm = new ResultsForm()) { this.Visible = false; frm.ShowDialog(); this.Visible = true; }在等待表单最终显示时,我将默认光标移到Cursors.WaitCursor是很有用的。 目前,我似乎只能通过使用静态'Current'属性来成功完成此操作:
using (ResultsForm frm = new ResultsForm()) { //this.Visible = false; Cursor.Current = Cursors.WaitCursor; frm.ShowDialog(); //this.Visible = true; }但这有两个问题:
它迫使我禁用我想保留的MainForm隐藏功能。 它增加了耦合,因为Cursor.Current = Cursor.Default; 需要在ResultsForm Shown事件中调用。如何在表单加载时更改光标而不更改第一个代码片段并避免耦合?
更新:现在问题得到解答,视频演示被删除,所以我不会超过我的ISP带宽限制。
I'm having a form that takes a few seconds to finally display. This form is called through:
using (ResultsForm frm = new ResultsForm()) { this.Visible = false; frm.ShowDialog(); this.Visible = true; }It's useful that I get the default cursor to Cursors.WaitCursor while waiting for the form to finally display. Currently I can only seem to be able to do this successfully by using the static 'Current' property:
using (ResultsForm frm = new ResultsForm()) { //this.Visible = false; Cursor.Current = Cursors.WaitCursor; frm.ShowDialog(); //this.Visible = true; }But this has two problems:
It forces me to disable the MainForm hiding feature which I would like to retain. It increases coupling since Cursor.Current = Cursor.Default; needs to be called within the ResultsForm Shown event.How can I change the Cursor while the form loads without changing the first code snippet and while avoiding coupling?
UPDATE: Now the question was answered, video presentation was removed so I don't go over my ISP bandwidth limitations.
最满意答案
你为什么要删除this.Visible = false? 您仍然可以在设置光标时执行此操作。
将ResultsForm设置为光标而不是父窗体是否是可接受的解决方案? 让它在启动始终占用的代码之前设置光标,然后在结束时将其设置回来。
Why do you have to remove the this.Visible = false? You should still be able to do it while setting the cursor.
Would it be an acceptable solution to have the ResultsForm set the cursor instead of the parent form? Get it to set the cursor before it starts the code that takes all the time, then set it back at the end.
更多推荐
发布评论