运行代码时Windows窗体无法正确显示 [英] Windows Form not properly displayed when running code

查看:52
本文介绍了运行代码时Windows窗体无法正确显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有使用Visual Basic编写应用程序的经验,因此这是遇到的问题:

I am not experienced writing application using visual basic, so here is the problem encountered:

我想创建一个Windows窗体应用程序,该程序将对硬盘进行一些处理,然后在完成时关闭.通过更新label2.text可以显示运行状态.

I wanted to create a windows form application that would do some processing on the harddisk, then close when it finishes. The status of running would be shown via updating the label2.text.

所以我用Windows窗体创建了一个项目.在简单的Windows窗体form1上,我添加了图像和一些文本标签.

So I created a project with Windows form. And on the simple Windows form form1, I added an image and a few text labels.

我的代码如下所示.我想知道为什么我的Windows窗体内容在应用程序运行时不能正确绘制/显示吗?我只看到窗口和标题,但是窗口内的所有内容都是空白或未正确绘制/绘制.好像我有 使用MsgBox指令暂停应用程序,那么我可以看到Windows窗体的内容.有任何线索吗?

My code is shown as below. I wonder why is my windows form content not painted/shown properly when the application is running? I only see the window and the title, but anything within the window is blank or not drawn/painted properly. It looks like I have to pause the application with a MsgBox instruction, then I can see the Windows form contents. Any clues?

导入System.IO
导入System.Text.RegularExpressions
导入System.Xml

公共课程表格1

   私有子Form1_Load(ByVal发送者为System.Object,
            ByVal e As System.EventArgs)处理MyBase.Load
        Console.WriteLine("blah blah")
        Label2.Text =开始使用HC"
        Dim workingFolder1 ="\\ hc-fs-01 \ Audio \ Public \"

Imports System.IO
Imports System.Text.RegularExpressions
Imports System.Xml

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object,
            ByVal e As System.EventArgs) Handles MyBase.Load
        Console.WriteLine("blah blah")
        Label2.Text = "Started For HC"
        Dim workingFolder1 = "\\hc-fs-01\Audio\Public\"

          ......一些for循环读取磁盘并写入文件的方法....

         ...... some for loop reading the disk and writing to a file ....

推荐答案

您可能必须强制执行刷新/更新控件,以便它们
在程序进入冗长的文件处理循环之前需要重新绘制.

示例:

Label2.Text =开始使用HC"
Label2.Update()

-韦恩

You may have to force a refresh/update of the controls so that they
get redrawn before your program goes into a lengthy file processing loop.

Example:

Label2.Text = "Started For HC"
Label2.Update()

- Wayne


这篇关于运行代码时Windows窗体无法正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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