我对 devexpress AlertControl 有一个奇怪的问题。我使用这段代码创建了一个 alertu
AlertInfo alertInfo = new AlertInfo(caption, text);
AlertControl control = new AlertControl();
control.FormLocation = AlertFormLocation.BottomRight;
control.Show(null,alertInfo);
这段代码放在 backgroundWorker_DoWork 函数中,它应该不时显示警报。问题是没有显示警报。我可以看到调用了 show 方法,但未显示警报。 根据文档,我将 null 作为 Show 函数的参数传递,通知应显示在主监视器上。 我该怎么做才能让它发挥作用?
最佳答案
考虑到您使用的是 worker,我猜这是一个线程问题。尝试将您的代码包装在 Action
对象中:
Action action = () =>
{
AlertControl control = new AlertControl();
control.FormLocation = AlertFormLocation.BottomRight;
control.Show(this, alertInfo); // "this" being a Form
};
this.Invoke(action);
我在表单中使用了类似的代码并取得了良好的效果,并且曾经使用 AlertControl
也做了类似的代码。
关于c# - AlertControl 不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7360453/