我对 devexpress AlertControl 有一个奇怪的问题。我使用此代码创建了一个警报

 AlertInfo alertInfo = new AlertInfo(caption, text);
    AlertControl control = new AlertControl();
    control.FormLocation = AlertFormLocation.BottomRight;
    control.Show(null,alertInfo);

此代码放置在 backgroundWorker_DoWork 函数中,它应该不时显示警报。问题是没有显示警报。我可以看到调用了 show 方法,但是没有显示警报。
根据文档,我将 null 作为 Show function 的参数传递,通知应显示在主监视器上。
我该怎么做才能让它发挥作用?

最佳答案

考虑到您正在使用 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/

10-11 04:13