如何在vb.net中更新标签文本 [英] how to update label text in vb.net

查看:76
本文介绍了如何在vb.net中更新标签文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的vb.net winform应用程序中,单击开始"按钮时,label1.text应该是进程已启动",然后某些文件保存方法将在完成后运行,该方法将label1.text更改为文件已保存". />

In my vb.net winform application, on click of start button the label1.text should be "process started" then some filesaving method will run after finish that method the label1.text should change to "file saved".

Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
        
        lblStatus.ForeColor = Color.Red
        lblStatus.Text = "Saving to File"
         
         'Get the values and write to xls
                 Trigger()
                 SaveXls()
            
         lblStatus.Text = "File Saved"
         lblStatus.ForeColor = Color.Green



标签保存到文件"的初始状态不是即将出现.触发方法完成后,标签的状态将更改为文件已保存"

有任何建议吗?



the initial status of label "saving to file" is not comingup. after the Trigger method finished, the status of the label is changing to "File saved"

Any suggestions please?

推荐答案

听起来像您需要研究 ^ ]或其他多线程方法.

您需要将Trigger和SaveXls方法放在单独的线程上,以便可以更新显示表单和标签的当前线程.您可以找到一些 CP文章 [这一个 [
Sounds like you need to research the BackgroundWorker[^] or other methods of multi-threading.

You need to put the Trigger and SaveXls methods on a separate thread so that you can update the current thread that is displaying the form and the label. You can find some CP articles[^] the could help you. This one[^] looks promising.


这篇关于如何在vb.net中更新标签文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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