c# - AlertControl 不显示

标签 c# winforms devexpress

我对 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/

相关文章:

c# - 用 C# 属性替换 XML 注释的正则表达式

c# - 如何删除整个数据库并使用 sql 和 c# 重新创建它?

c# - 如何在 C# WinForm 自定义用户控件中设置文本对齐指示器?

c# - Gridview 行选择和编辑

asp.net - Azure 网站和自定义字体

c# - 如何在运行时运行 Devexpress 报表设计器?

javascript - 如何在ascx中获取客户端id devexpress控制

c# - MongoDB for .Net简单显示数据示例

c# - 检测unity中引用的其他对象值的变化?

c# - 将 SQL Server 中的数据加载到组合框中