AlertControl Class |
The component that supports displaying alert windows.
Assembly:DevExpress.XtraBars.v14.1.dll
在應用程序中顯示警告窗口。 警告窗口是一個小窗,一般用來顯示很短時間,時間到達後自動關閉. 是一種通知窗口,在 Microsoft Outlook裏有實現.
alert window 可以通過 Show 方法創建 使用此方法,可以指定窗口標題、文本、圖像,而且可以通過tag標籤給窗體管理相關數據. 之後你可以在處理鼠標或其他alert windows事件中使用這些自定義數據.
See Alert Windows Overview to learn more.默認情況,警示窗口是半透明的. 以下代碼將使窗體不透明. 改變不透明度OpacityLevel(double 0-1,0爲透明,1爲不透明),處理 BeforeFormShow 事件.
|
||||||
|
Example 1:
新建一窗體項目,從工具箱的Navigation&Layout拖動AlertControl到窗體,AlertControl在窗體中是不可見的(應該說是組件),會顯示在Form下方。在AlertControl的屬性中選擇Buttons,添加Button集合,設置相應Button的屬性。
Button圖像可以通過Image屬性添加圖像,可以設置Button是普通按鈕還是有Check狀態的按鈕,這個通過Behavior的Style=CheckButton設置。
還可以給按鈕添加提示信息,通話Hint=text;來設置。
下面添加事件
第一個按鈕爲常規按鈕, 單擊觸發 ButtonClick 事件.
第二個按鈕有選中和未選中狀態. 單擊觸發 ButtonDownChanged 事件.
在AlertControl的Events中添加事件處理代碼。
AutoFormDelay屬性用來設置AlertWindow窗體延遲(即每一個AlertWindow顯示的時間,時間到達後會自動消失),單位:毫秒,默認7000ms,即7s
FormDisplaySpeed屬性用來設置AlertWindow窗口顯示速度
FormMaxCount數值用來設置AlertControl一次最多同時顯示多少個Window,爲0則不限制。
FormLocation用來設置AlertWindow顯示的位置(相對於整個屏幕),默認爲屏幕右下角BottomRight
其中PinButton、CloseButton所在位置爲ControlBoxPosition,可以在頂部或右側。
還可以添加Info的Caption、Text或Image被單擊時的處理事件,方法是在
private void alertControl1_AlertClick(object sender, DevExpress.XtraBars.Alerter.AlertClickEventArgs e)
{
MessageBox.Show(e.Info.Text);
}
中獲取e.Info的信息。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace RibbonApp.控件Samples
{
public partial class AlertControlForm : Form
{
public AlertControlForm()
{
InitializeComponent();
}
private void alertControl1_BeforeFormShow(object sender, DevExpress.XtraBars.Alerter.AlertFormEventArgs e)
{
e.AlertForm.OpacityLevel = 1;
}
private void alertControl1_ButtonClick(object sender, DevExpress.XtraBars.Alerter.AlertButtonClickEventArgs e)
{
if (e.ButtonName == "alertButton1")
{
}
}
private void alertControl1_ButtonDownChanged(object sender, DevExpress.XtraBars.Alerter.AlertButtonDownChangedEventArgs e)
{
if (e.ButtonName == "alertButton2")
{
}
}
private void btnShowAlertWindow_Click(object sender, EventArgs e)
{
DevExpress.XtraBars.Alerter.AlertInfo info = new DevExpress.XtraBars.Alerter.AlertInfo("標題", "這裏是警示信息");
alertControl1.Show(this,info);
}
private void alertControl1_AlertClick(object sender, DevExpress.XtraBars.Alerter.AlertClickEventArgs e)
{
MessageBox.Show(e.Info.Text);
}
}
}
Example2:原參考文檔:
下面展示如何給AlertControl.添加自定義按鈕。
假定 AlertControl 控件已經放置在Form上. 本例中,兩個自定義按鈕將被添加到控件的 Buttons collection. 第一個按鈕爲常規按鈕, 單擊觸發 ButtonClick 事件. 第二個按鈕有選中和未選中狀態. 單擊觸發 ButtonDownChanged 事件.
效果如下The result is shown below:
|
||||||
|
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
AlertControl