This is a migrated thread and some comments may be shown as answers.

Tracking number of open raddesktop alerts

5 Answers 180 Views
DesktopAlert
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 18 Jan 2011, 06:07 PM
Hi I want to show only upto 3 desktop alerts at any given time.  Some alerts have autoclose options while others do not.  As such before displaying an alert, I need to check how many are open.  I tried using the desktopalertmanager but running into null exception errors

Dim

 

iDesktopAlertManager As DesktopAlertManager
Dim value As IEnumerator(Of RadDesktopAlert)
value = iDesktopAlertManager.GetRegisteredAlerts()

 

I stepped though the code and the iDesktopAlertManager is nothing which causes a null exception error.  I am not fully aware of the DesktopAlertManager.

This is similar to the code sample on your reference pages so not sure what I am doing wrong here...
http://www.telerik.com/help/winforms/telerik.wincontrols.ui-telerik.wincontrols.ui.desktopalertmanager-getregisteredalerts.html

5 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 18 Jan 2011, 11:58 PM
Hello John,

Please can you try this in a new project. It's just a form and a RadButton

Private m_Alerts As New List(Of Telerik.WinControls.UI.RadDesktopAlert)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Alert_Closed(ByVal Sender As Object, ByVal e As EventArgs)
    m_Alerts.Remove(CType(Sender, Telerik.WinControls.UI.RadDesktopAlert))
End Sub
Private Sub ButtonGenerateAlert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGenerateAlert.Click
    If m_Alerts.Count < 3 Then
        Dim alert As New Telerik.WinControls.UI.RadDesktopAlert()
        alert.CaptionText = "Alert Header"
        alert.ContentText = "Alert Context"
        m_Alerts.Add(alert)
        alert.Show()
        AddHandler alert.Closed, AddressOf Alert_Closed
    End If
End Sub

Hope that helps
Richard
0
Richard Slade
Top achievements
Rank 2
answered on 20 Jan 2011, 10:11 AM
Hello,

Did this help? If so please remember to mark as answer. If you need morre assistance just let me know.
Regards,
Richard
0
Ivan Todorov
Telerik team
answered on 21 Jan 2011, 08:50 AM
Hello John,

Here is the proper way to use the DesktopAlertManager to get the count of the shown alerts:
Public Function GetAlertCount() As Integer
    Dim count As Integer = 0
    Dim alerts As IEnumerator(Of RadDesktopAlert) = DesktopAlertManager.Instance.GetRegisteredAlerts()
    While alerts.MoveNext()
        count += 1
    End While
 
    Return count
End Function

Richard's approach could also do the required task.

I hope this was helpful. Should you have any further questions, do not hesitate to ask.

Greetings,
Ivan Todorov
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
0
John
Top achievements
Rank 1
answered on 25 Jan 2011, 05:15 PM
I will try this option and update with my findings.
0
Ivan Todorov
Telerik team
answered on 28 Jan 2011, 08:24 AM
Hi John,

Please let us know if this worked for you, when you try it. I will be glad to assist you if you need further help, so do not hesitate to write back.

Greetings,
Ivan Todorov
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Tags
DesktopAlert
Asked by
John
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Ivan Todorov
Telerik team
John
Top achievements
Rank 1
Share this question
or