DesktopAlert Close in code

6 posts, 1 answers
  1. Joe Bohen
    Joe Bohen avatar
    62 posts
    Member since:
    May 2009

    Posted 19 Jun 2010 Link to this post

    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()

     

  2. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 24 Jun 2010 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jorge Delgado-Lopez
    Jorge Delgado-Lopez avatar
    82 posts
    Member since:
    Aug 2007

    Posted 11 Oct 2010 Link to this post

    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 
  5. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 11 Oct 2010 Link to this post

    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
  6. Rawad
    Rawad avatar
    23 posts
    Member since:
    Jan 2012

    Posted 01 Nov 2012 Link to this post

    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
  7. Anton
    Admin
    Anton avatar
    167 posts

    Posted 05 Nov 2012 Link to this post

    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready