[英]Binding programmatically generated DataGridTextColumn's Visibility property to a checkbox
[英]Threading: Setting checkbox's visibility
在C#.NET Windows应用程序(winforms)中,我将复选框的可见性设置为false:
checkBoxLaunch.Visible = true;
我开始了一个话题。
Thread th = new Thread(new ThreadStart(PerformAction));
th.IsBackground = true;
th.Start();
该线程执行一些操作并将可见性设置为true:
private void PerformAction()
{
/*
.
.// some actions.
*/
checkBoxLaunch.Visible = true;
}
线程完成其任务后,该复选框对我不可见。
我想念什么?
您不应该在非UI线程内进行UI更改。 使用Control.Invoke
, Control.BeginInvoke
或BackgroundWorker
将呼叫Control.BeginInvoke
送回UI线程。 例如(假设C#3):
private void PerformAction()
{
/*
.
.// some actions.
*/
MethodInvoker action = () => checkBoxLaunch.Visible = true;
checkBoxLaunch.BeginInvoke(action);
}
搜索Control.Invoke,Control.BeginInvoke或BackgroundWorker中的任何内容,以查找有关此内容的数百篇文章。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.