调用状态栏的进度条?
it1352
帮助1人
问题说明
我正在使用以下代码来调用应用程序中主UI线程上的控件.我的状态栏中的进度栏没有InvokeRequired,我需要以某种方式调用System.Windows.Forms.ToolStripProgressBar.
I am using the following code to invoke the controls that are on the main UI thread in my application. The progress bar that I have in my Status Strip does not have a InvokeRequired, I need to somehow invoke the System.Windows.Forms.ToolStripProgressBar.
if (txtbox1.InvokeRequired)
{
txtbox1.Invoke(new MethodInvoker(delegate { txtbox1.Text = string.Empty; }));
}
正确答案
#1
自己找到了.
Found it myself.
System.Windows.Forms.ToolStripProgressBarprgBarMain.GetCurrentParent().InvokeRequired
Sevak是正确的!如果控件没有控件,则可以始终使用父控件的"InvokeRequired".
或者,您始终可以使用PInvoke检查当前线程是否与主线程不同.如果线程不同,则无需使用Invoke.如果您愿意,我可以共享该代码.
希望对您有所帮助!
Sevak is right! You can always use parent''s "InvokeRequired" if the control doesn''t have one...
Alternately you can always check if the current thread is different from the main thread using PInvoke. If the threads are different you need to use Invoke else not. If you want I can share the code for that.
Hope that helps!
这可能对您有帮助
This might be help you
this.BeginInvoke((ThreadStart)delegate()
{
//UI change code goes here
});
谢谢
Thanks
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcfkehf
系列文章
更多
同类精品
更多
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20