下面的示例展示了如何对最终用户单击提醒窗口的文本作出响应。 要响应这些操作,则接管 AlertControl.AlertClick 事件。
在本示例中,假设当新电子邮件到达时,提醒窗口可以用于对最终用户显示通知。 当新建提醒窗口时,一个自定义的 MailData 对象与此窗口相关联。 此对象包含了关于所接收电子邮件的信息,并且在接管 AlertControl.AlertClick 事件时被访问和处理。
C# | 复制代码 |
---|---|
private void ShowAlertWindow() { Form owner; string caption, text, hotTrackedText; Image image; MailData mailData; // Initialize the owner, caption, text, hotTrackedText, image and mailData // ... // Show an alert window with these parameters alertControl1.Show(owner, caption, text, hotTrackedText, image, mailData); } private void alertControl1_AlertClick(object sender, AlertClickEventArgs e) { // Get and process the data associated with the current alert window. MailData mailData = e.Info.Tag as MailData; ShowEmail(mailData); } private void ShowEmail(MailData mailData) { //... } public class MailData { //... } |
Visual Basic | 复制代码 |
---|---|
Private Sub ShowAlertWindow() Dim owner As Form Dim caption, text, hotTrackedText As String Dim image As Image Dim mailData As MailData ' Initialize the owner, caption, text, hotTrackedText, image and mailData ' ... ' Show an alert window with these parameters alertControl1.Show(owner, caption, text, hotTrackedText, image, mailData) End Sub Private Sub AlertControl1_AlertClick(ByVal sender As System.Object, _ ByVal e As AlertClickEventArgs) Handles AlertControl1.AlertClick ' Get and process the data associated with the current alert window. Dim mailData As MailData = TryCast(e.Info.Tag, MailData) ShowEmail(mailData) End Sub Private Sub ShowEmail(ByVal mailData As MailData) '... End Sub Public Class MailData '... End Class |