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

DesktopAlert Close in code

5 Answers 419 Views
DesktopAlert
This is a migrated thread and some comments may be shown as answers.
Joe Bohen
Top achievements
Rank 1
Joe Bohen asked on 19 Jun 2010, 10:27 AM

Hi
I am adding RadDesktopAlerts programmable using the following code a button is added along with a handler when the button is clicked I would like to process the event and then close the alert! Is this possible?

 Regards
Joe

                      Dim
Popup As New RadDesktopAlert

                    Popup.AlertImage = Me.ImageList1.Images(3)

                    Popup.AlertImage.Tag = 1

                    Popup.CaptionText = PopData.Rows(i).Item("msgTitle").ToString

                    Popup.ContentText = PopData.Rows(i).Item("msgBody").ToString

                    Dim bt As New RadButtonElement

                    bt.Text = "Dismiss " & PopData.Rows(i).Item("ID").ToString

                    bt.Tag = PopData.Rows(i).Item("ID").ToString

                    AddHandler bt.Click, AddressOf SetPop

                    Popup.ButtonItems.Add(bt)

                    Popup.Show()

 

5 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 24 Jun 2010, 08:47 AM
Hello Joe,

Thanks for writing and for your question.

Yes, you can use the Hide method of the RadDesktopAlert component in your event handler to hide the desktop alert upon clicking on the button.
this.radDesktopAlert1.Hide();

Do not hesitate to write back anytime you have further questions or need assistance.

Sincerely yours,
Deyan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
superold
Top achievements
Rank 1
answered on 11 Oct 2010, 07:44 PM
Hello.

I cannot seem to get Hide() to work. I create the DesktopAlert in runtime, set AutoClose to false and Hide() it when needed.

I have also tried to set the AutoClose to true and AutoCloseDelay = 1 in runtime to get it to close, but no luck.

Anyone else with this problem?

- jorge 
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 11 Oct 2010, 08:32 PM
Hello Jorge Delgado-Lopez,

Please try the following example, everything is working as expected here, with Telerik Controls version Q2 2010 SP2:

Imports Telerik.WinControls.UI
 
Public Class Form1
    Dim Popup As New RadDesktopAlert
    Dim WithEvents ButtonOpen As New RadButton
    Dim WithEvents ButtonClose As New RadButton
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ButtonOpen.Dock = DockStyle.Bottom
        ButtonOpen.Text = "Open"
        ButtonClose.Dock = DockStyle.Bottom
        ButtonClose.Text = "Close"
        Me.Controls.Add(ButtonOpen)
        Me.Controls.Add(ButtonClose)
    End Sub
 
    Private Sub ButtonOpen_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonOpen.Click
        Popup.CaptionText = "Caption"
 
        Popup.ContentText = "Content"
 
        If (Popup.ButtonItems.Count = 0) Then
            Dim bt As New RadButtonElement
 
            bt.Text = "Dismiss"
 
            AddHandler bt.Click, AddressOf SetPop
 
            Popup.ButtonItems.Add(bt)
        End If
 
        Popup.Show()
    End Sub
 
    Private Sub ButtonClose_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonClose.Click
        Popup.Hide()
    End Sub
 
    Private Sub SetPop(ByVal sender As Object, ByVal e As EventArgs)
        Popup.Hide()
    End Sub
End Class

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
0
Rawad
Top achievements
Rank 2
answered on 01 Nov 2012, 09:31 AM
Hello

Can any one help please.

I want to show multiple DesktopAlert, and when the user click on the button (inside the Desktop Alert), i want to hide it.
Here is my code:

For i = 0 To 5
            Dim s As New RadButtonElement("click me " & i)
            s.Tag = i

            Dim desk As New RadDesktopAlert()
            desk.CaptionText = "New E-mail Notification"
            desk.ContentText = "testing " & i
            desk.AutoClose = False
            AddHandler s.Click, AddressOf AAA
            desk.ButtonItems.Add(s)

            m_Alerts.Add(desk)
            desk.Show()

        Next


Private Sub AAA(sender As System.Object, e As System.EventArgs)
        Dim txt As RadButtonElement = CType(sender, RadButtonElement)
        MessageBox.Show(txt.Tag) ' here to display the id of the button
       
        '
how to hide the DesktopAlert . . .. .


    End Sub


Thanks
0
Anton
Telerik team
answered on 05 Nov 2012, 02:37 PM
Hello Rawad,

Thank you for writing.

Here is the modified version of your code that will help you achieve the desired functionality :
Dim dic As New Dictionary(Of RadButtonElement, RadDesktopAlert)()
 
Private Sub AAA(sender As System.Object, e As System.EventArgs)
    Dim txt As RadButtonElement = CType(sender, RadButtonElement)
    dic(txt).Hide()
    MessageBox.Show(txt.Tag) ' here to display the id of the button
 
End Sub
 
Private Sub RadButton1_Click(sender As System.Object, e As System.EventArgs) Handles RadButton1.Click
 
    For i = 0 To 5
        Dim s As New RadButtonElement("click me " & i)
        s.Tag = i
 
        Dim desk As New RadDesktopAlert()
        desk.CaptionText = "New E-mail Notification"
        desk.ContentText = "testing " & i
        desk.AutoClose = False
        AddHandler s.Click, AddressOf AAA
        desk.ButtonItems.Add(s)
        dic.Add(s, desk)
        desk.Show()
    Next
End Sub
Attached is a sample project that comprises the code above. I hope this helps.

Should you have any other questions, I will be glad to assist you.

Regards,
Anton
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
DesktopAlert
Asked by
Joe Bohen
Top achievements
Rank 1
Answers by
Deyan
Telerik team
superold
Top achievements
Rank 1
Emanuel Varga
Top achievements
Rank 1
Rawad
Top achievements
Rank 2
Anton
Telerik team
Share this question
or