AlertControl.BeforeFormShow Event
Allows you to customize an alert window’s contents, size, and position before the window is displayed.
Namespace: DevExpress.XtraBars.Alerter
Assembly: DevExpress.XtraBars.v24.2.dll
Declaration
Event Data
The BeforeFormShow event's data class is DevExpress.XtraBars.Alerter.AlertFormEventArgs.
Remarks
Handle the BeforeFormShow
event to customize an alert window before it is displayed on-screen.
Use the following options to change an alert window’s main settings:
e.AlertForm.Info
— An object that allows you to access and change the alert window’s caption, description, and other display options.e.AlertForm.OpacityLevel
— The window’s opacity level.Alert windows appear on-screen with a fade-in effect. The
OpacityLevel
parameter specifies the final opacity level of the fade-in effect. The0
value means the window is transparent, and1
makes the window opaque.e.AlertForm.Size
— The window’s size.e.Location
— The window’s location. The default window location is specified by the AlertControl.FormLocation property.
HTML-CSS Templates
AlertControl can render alert windows from HTML-CSS templates. You can handle the BeforeFormShow
event to assign templates to alert windows dynamically.
private void alertControl1_BeforeFormShow(object sender, DevExpress.XtraBars.Alerter.AlertFormEventArgs e) {
AlertControl alertControl = sender as AlertControl;
if (e.HtmlPopup.AlertInfo.Tag != null)
e.HtmlPopup.HtmlTemplate.Assign(alertControl.HtmlTemplates[1]);
}
See the following topic for more information: Alert Windows with HTML Templates.
Example
This example displays an alert window and demonstrates how to respond to clicking the alert window’s content. The shown alert window is made opaque in the BeforeFormShow event handler.
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ShowAlertWindow {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void simpleButton1_Click(object sender, EventArgs e) {
Message msg = new Message();
alertControl1.Show(this, msg.Caption, msg.Text, "", msg.Image, msg);
}
private void alertControl1_BeforeFormShow(object sender, DevExpress.XtraBars.Alerter.AlertFormEventArgs e) {
//Make the Alert Window opaque
e.AlertForm.OpacityLevel = 1;
}
private void alertControl1_AlertClick(object sender, DevExpress.XtraBars.Alerter.AlertClickEventArgs e) {
//Process Alert Window click
Message msg = e.Info.Tag as Message;
XtraMessageBox.Show(msg.Text, msg.Caption);
}
}
public class Message {
public Message() {
this.Caption = "LILA-Supermercado";
this.Text = "Carrera 52 con Ave. Bolívar #65-98 Llano Largo";
this.Image = global::ShowAlertWindow.Properties.Resources.opportunities_32x32;
}
public string Caption { get; set; }
public string Text { get; set; }
public Image Image { get; set; }
}
}