实时刷新winform中的某一个控件上的文字
需要注意的是,必须从UI线程,另外启动一个线程才可以。
在新线程调用异步刷新就OK了
Thread thread;
private void button1_Click(object sender, EventArgs e)
{
thread = new Thread(new ThreadStart(AnotherRefresh));
thread.IsBackground = true;
thread.Start();
}
private void AnotherRefresh()
{
MyRefresh("hello world");
Thread.Sleep(1000);
MyRefresh("Bye Bye");
}
private void MyRefresh(string str)
{
try
{
this.Invoke((MethodInvoker)delegate()
{
textBox1.Text = str;
});
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
实时刷新winform中的某一个控件上的文字的更多相关文章
- WinForm中使用AnyCAD三维控件 の 初始化
在WinForm中可以方便的集成AnyCAD.Net三维控件,只需要以下几部即可完成. 一.添加DLL程序集 AnyCAD.Foundation.Net.dll AnyCAD.Presentation ...
- android自定义控件(6)-详解在onMeasure()方法中如何测量一个控件尺寸
今天的任务就是详细研究一下protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)方法.如果只是说要重写什么方法有什么 ...
- winform中的时间轴控件
我现在做的项目遇到一个需求,就是有没有类似的控件: 我要实现的功能是:播放录像. 某个时间段内假如有2个录像,这个坐标表示的是时间,假如我现在拖动时间轴,拖到第一个录像里面开始播放第一个录像,拖到2个 ...
- c#winform中如何修改ListView控件每个单元格的颜色
ListView在View属性为Details的时候它呈现的方式和DataGirdView差不多,它的每一行都是一个ListViewItem,然而每个ListViewItem都有一个BackColor ...
- winform中如何使用timer控件实现欢迎(初始加载)窗口
第一步.新建窗体项目命名为:TestWelcomeFrm,如下图: 第二步.在新项目中,增加欢迎窗口,命名为WelFrm,整个项目目录如下: 第三步.修改program.cs中启动代码如下: WelF ...
- 实时刷新Winform中Label的Text
最直白的例子: private void btnStart_Click(object sender, EventArgs e) { ; ) { labelTime.Text = i.ToString( ...
- 【原创】WinForm中实现单独Time控件的方式
WinForm默认只提供了DateTimePicker,今天的项目只用时间,不能出现日期,百撕不得骑姐(^^),也没花多少时间,随便试了一下,就成功了,分享一下. 在DateTimePicker属性中 ...
- WinForm中使用自定义Tooltip控件
private ToolTip tooltipCtr; 构造函数中: 隐藏默认的Tooltip:this.ShowCellToolTips = false; this.tooltipCtr = new ...
- WinForm/Silverlight多线程编程中如何更新UI控件的值
单线程的winfom程序中,设置一个控件的值是很easy的事情,直接 this.TextBox1.value = "Hello World!";就搞定了,但是如果在一个新线程中这么 ...
随机推荐
- font-size对展示的影响
实例: <head> <style type="text/css"> span{display: inline-bloc ...
- url-loader与file-loader
一开始用url-loader的时候,想着为什么npm run build的时候,不能将图片打包到build images的目录下,原来,没有自己看这样的说明: loader 后面 limit 字段代表 ...
- 关于PreparedStatement.addBatch()方法 (转)
Statement和PreparedStatement的区别就不多废话了,直接说PreparedStatement最重要的addbatch()结构的使用. 1.建立链接,(打电话拨号 ) Connec ...
- 【BZOJ1630/2023】[Usaco2007 Demo]Ant Counting DP
[BZOJ1630/2023][Usaco2007 Demo]Ant Counting 题意:T中蚂蚁,一共A只,同种蚂蚁认为是相同的,有一群蚂蚁要出行,个数不少于S,不大于B,求总方案数 题解:DP ...
- Windows Phone 7 检查手机网络
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Wi ...
- Thinkphp --- 去掉index.php
这里我使用的面板是宝塔,操作的 apche: 具体的配置可以参考这里: https://www.cnblogs.com/fangziffff123/p/7588782.html 首先是:Thinkph ...
- 再谈js的作用域
再谈js的作用域 面试中遇到的题目: 题目一: var word = "hello world"; (function(){ alert(word); var word = ...
- CodeForces 17D Notepad(同余定理)
D. Notepad time limit per test 2 seconds memory limit per test 64 megabytes input standard input out ...
- Python开发【Django】:重构Admin
自定义KingAdmin 通过admin样式自己做KingAdmin 提前需知道的model操作 # 获取app名 >>> models.Customer._meta.app_lab ...
- IntelliJ IDEA 、PyCharm、WebStorm、PhpStorm等JetBrains公司软件 激活的License Server本地搭建教程
一.背景 IntelliJ IDEA是JetBrains公司的一款IDE,主要用于java开发,可以编写Java.Groovy.Kotlin.Scala等语言,也可以直接做Android开发. 同系列 ...