开发者

C# how can I open a box to update the user on progress?

I want to open a window that will display some text like "Validating input" a开发者_如何学Gond hold it open until a method is finished. I can't do this with messagebox. Any ideas guys?


Unless I've misunderstood this sounds a tad cruel to the user, but you could do something like this:

A MessageBox is just a standard Windows Form shown as a modal dialog. If you don't like the controls displayed on the form then you can create your own form and show it to the user as a modal dialog through the ShowDialog method:

MyDialog dialog = new MyDialog();
dialig.ShowDialog();

Your MyDialog form can then either perform the validation itself, or respond to notification that the validation has completed. Until the dialog has been dismissed the user won't be able to interact with the rest of the app (just as when a message box is shown) and the dialog could even disable buttons / prevent the user from closing it until the validation has succeeded.

If you do this and your modal dialog isn't performing the validation then you should be aware that you will need to perform the validation on a background thread, as the UI thread will be tied up displaying the modal dialog.


You can create a basic form, and do something like this.

this.Enabled = false;
FormWaiting frm = new FormWaiting();
frm.Show();

Thread.Sleep(1000000); //Place holder for long operation.
frm.Close();
this.Enabled = true;


Depends on your app context you can pick up example of @Jethro, or

Create a your FormWaiting:Form , make it topmost and call Show(), one time your method finished execution close it.

There is a lot other stuff that you can do, but depends on yuor concrete context which can not be very clear from the post.

Hope this helps.

Regards.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜