reminderBindableObjects

6 posts, 0 answers
  1. Rafael
    Rafael avatar
    10 posts
    Member since:
    Dec 2015

    Posted 08 Jul Link to this post

    How can I access the reminderBindableObjects from the RadSchedulerReminder1_AlarmFormShowing event?

     

    Thanks,

     

    Rafael

  2. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 11 Jul Link to this post

    Hello Rafael,

    Thank you for writing. 

    You can extract the RadReminderBindableObject by the RadGridView that is shown on the form. Here is a sample code snippet: 
    this.radSchedulerReminder1.AlarmFormShowing += radSchedulerReminder1_AlarmFormShowing;
     
    this.radSchedulerReminder1.AssociatedScheduler = this.radScheduler1;
    this.radSchedulerReminder1.StartReminderInterval = DateTime.Now.AddDays(-1);
    this.radSchedulerReminder1.EndReminderInterval = DateTime.Now.AddDays(1);
    this.radSchedulerReminder1.TimeInterval = 5000;
    this.radScheduler1.Appointments.Add(new Appointment(DateTime.Now.AddMinutes(20),TimeSpan.FromMinutes(45),"Meeting A"));
    ((Appointment)this.radScheduler1.Appointments[0]).Reminder = TimeSpan.FromMinutes(20);
    this.radScheduler1.Appointments.Add(new Appointment(DateTime.Now.AddMinutes(20),TimeSpan.FromMinutes(45),"Meeting B"));
    ((Appointment)this.radScheduler1.Appointments[1]).Reminder = TimeSpan.FromMinutes(20);
     
    this.radSchedulerReminder1.StartReminder();


    private void radSchedulerReminder1_AlarmFormShowing(object sender, RadAlarmFormShowingEventArgs e)
    {
        RadAlarmForm f = e.AlarmForm as RadAlarmForm;
        if (f != null)
        {
            f.Shown -= f_Shown;
            f.Shown += f_Shown;
        }
    }
     
    private void f_Shown(object sender, EventArgs e)
    {
        RadAlarmForm f = sender as RadAlarmForm;
        if (f != null)
        {
            BindingList<RadReminderBindableObject> reminderBindableObjects;
            RadGridView grid = f.Controls["radGridViewEvents"] as RadGridView;
            reminderBindableObjects = grid.DataSource as BindingList<RadReminderBindableObject>;
            Console.WriteLine(reminderBindableObjects.Count);
        }
    }

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Rafael
    Rafael avatar
    10 posts
    Member since:
    Dec 2015

    Posted 11 Jul in reply to Dess Link to this post

    Hi Tess Could you please explain what the instructions

            f.Shown -= f_Shown;
            f.Shown += f_Shown;

    are doing or if you could post the sipnet in VB.

     

    Thanks,

     

    Rafael

  5. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 12 Jul Link to this post

    Hello Rafael,

    Thank you for writing back. 

    The purpose of the referred code snippet is to have only one subscription to the RadAlarmForm.Shown event because the AlarmFormShowing event is supposed to be fired more than once. Here is the relevant code in VB.NET:
    Public Sub New()
        InitializeComponent()
        AddHandler Me.RadSchedulerReminder1.AlarmFormShowing, AddressOf radSchedulerReminder1_AlarmFormShowing
        Me.RadSchedulerReminder1.AssociatedScheduler = Me.RadScheduler1
        Me.RadSchedulerReminder1.StartReminderInterval = DateTime.Now.AddDays(-1)
        Me.RadSchedulerReminder1.EndReminderInterval = DateTime.Now.AddDays(1)
        Me.RadSchedulerReminder1.TimeInterval = 5000
        Me.RadScheduler1.Appointments.Add(New Appointment(DateTime.Now.AddMinutes(20), TimeSpan.FromMinutes(45), "Meeting A"))
        DirectCast(Me.RadScheduler1.Appointments(0), Appointment).Reminder = TimeSpan.FromMinutes(20)
        Me.RadSchedulerReminder1.StartReminder()
    End Sub
     
    Private Sub radSchedulerReminder1_AlarmFormShowing(sender As Object, e As RadAlarmFormShowingEventArgs)
        Dim f As RadAlarmForm = TryCast(e.AlarmForm, RadAlarmForm)
        If f IsNot Nothing Then
            Console.WriteLine("alarm")
            RemoveHandler f.Shown, AddressOf f_Shown
            AddHandler f.Shown, AddressOf f_Shown
        End If
    End Sub
     
    Private Sub f_Shown(sender As Object, e As EventArgs)
        Dim f As RadAlarmForm = TryCast(sender, RadAlarmForm)
        If f IsNot Nothing Then
            Dim reminderBindableObjects As BindingList(Of RadReminderBindableObject)
            Dim grid As RadGridView = TryCast(f.Controls("radGridViewEvents"), RadGridView)
            reminderBindableObjects = TryCast(grid.DataSource, BindingList(Of RadReminderBindableObject))
            Console.WriteLine(reminderBindableObjects.Count)
        End If
    End Sub

    Feel free to use the online code converter in future to convert C# to VB.NET and vice versa: http://converter.telerik.com/

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  6. Rafael
    Rafael avatar
    10 posts
    Member since:
    Dec 2015

    Posted 13 Jul in reply to Dess Link to this post

    Hi Dess,

     

    I run the snippet you post and it works but I seeing that the f_Shown rutine only executes on the first appointment reminder that I set. On the second one the standard alarm form shows up but without executing the f_Shown code. Do you have an idea why is this?

  7. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 14 Jul Link to this post

    Hello Rafael,

    Thank you for writing back. 

    The RadAlarmForm.Shown event occurs whenever the form is first displayed. The Shown event is only raised the first time a form is displayed; subsequently minimizing, maximizing, restoring, hiding, showing, or invalidating and repainting will not raise this event. Feel free to use the Form.VisibleChanged event which si fired each time the form is displayed or hidden: 
    Private Sub radSchedulerReminder1_AlarmFormShowing(sender As Object, e As RadAlarmFormShowingEventArgs)
        Dim f As RadAlarmForm = TryCast(e.AlarmForm, RadAlarmForm)
        If f IsNot Nothing Then
            Console.WriteLine("alarm")
            RemoveHandler f.VisibleChanged, AddressOf f_VisibleChanged
            AddHandler f.VisibleChanged, AddressOf f_VisibleChanged
        End If
    End Sub
     
    Private Sub f_VisibleChanged(sender As Object, e As EventArgs)
        Dim f As RadAlarmForm = TryCast(sender, RadAlarmForm)
        If f IsNot Nothing Then
            Dim reminderBindableObjects As BindingList(Of RadReminderBindableObject)
            Dim grid As RadGridView = TryCast(f.Controls("radGridViewEvents"), RadGridView)
            reminderBindableObjects = TryCast(grid.DataSource, BindingList(Of RadReminderBindableObject))
            Console.WriteLine(reminderBindableObjects.Count)
        End If
    End Sub

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready