c#标签为“空"/为表格中的孔 [英] c# Label is "empty"/is a hole in the form

查看:56
本文介绍了c#标签为“空"/为表格中的孔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个窗口.主窗体和加载窗体.在主表单中,您发送一个将被执行的请求.因为这需要一些时间,所以我用进度条制作了加载"表单,以便用户知道程序正在运行.

I have 2 windows. The main form and the Loading form. In the main form you send a request which will be executed. Because this takes some time, I made the Loading-form with a progress bar so that the user knows the program is working.

我想要的是:加载文件应在流程开始时打开,并在完成时关闭. 目前,我的代码看起来像这样:

What I want to: The Loading-form should open itself when the process ist started and close itself when it's finished. At the moment I have code that looks something like this:

    Loading.Show();
    Loading.MakeAStep();    //used for progressing the progress bar

    //program is working

    //finishes
    Loading.Visible = false;
    Loading.ResetProgress();    //Sets the value of the progress bar to 0

我的问题是:带有进度栏的窗口将打开,但是还有一个标签显示请稍候".当表单打开时,进度条可以完美地工作,但是标签只是一个洞(实际上是您可以浏览的洞).当我使用而不是visible = false form.Close时,该标签可以很好地工作,但是当我尝试在同一会话中开始进度时出现错误. 我想要/需要的是:解决孔洞问题的方法,或者是在一个会话中多次打开和关闭表单的有效方法.

My problem is: The window with the progress bar opens, but there is also a label which shows "please wait". When the form opens, the progress bar works perfectly, but the label is just a hole (it really is you can look through it). When I use instead of visible = false form.Close, it works just fine with the label but I get an error when I try to start a progress in the same session. What I want/need: Either a solution to the hole-problem, or an effective way to open and close a form several times during one session.

推荐答案

(代表OP发布).

答案在注释中:UI块被阻止了,我需要使用Loading.Update();更新表单,我将其放在Show和MakeAStep之间.

The answer is in the comments: The UI blocks and I needed to Update the form with Loading.Update(); I put that between Show and MakeAStep.

这篇关于c#标签为“空"/为表格中的孔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆