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

Custom Items

5 Answers 159 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Jeremy Murtishaw
Top achievements
Rank 1
Jeremy Murtishaw asked on 10 Aug 2009, 09:37 PM
I have created a new EditAppointDialog form, using a custom Appointment Factory.  C#

1)  How can I set the new custom appointment data during manual creation?  I don't see "Email" show as an option.  Am I missing something?  The email data does save & load within the session.   


Appointment appointment = null;
appointment = new Appointment(start, end, summary, description, location);
this.radScheduler.Appointments.Add(appointment);


this.radScheduler.AppointmentFactory = new CustomSchedFactory();


public class CustomSchedFactory : IAppointmentFactory
    {
        #region IAppointmentFactory Members

        public IEvent CreateNewAppointment()
        {
            return new MySched();
        }

        #endregion
    }

public class MySched : Appointment
    {
        public MySched() 
            :base()
        { }

        string email = String.Empty;

        public string Email
        {
            get { return this.email; }
            set 
            {
                if (this.email != value)
                {
                    this.email=value;
                    this.OnPropertyChanged("Email");
                }
            }
        }



2)  I also will have a new combobox added to the custom AppointmentDialog, and I want to add items at form load (similiar to Resources). How I can I add drop-down values to my custom combobox on the radScheduler during Onload of RadForm (not Appointment form)?

this.radScheduler.Resources.Add(new Resource(1,"Test"));
(I have a new "Types" combobox on the custom EditAppointmentDialog)



5 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 12 Aug 2009, 07:16 AM
Hi Jeremy Murtishaw,

Lets see if I understand you correctly. By manual creation you mean with the "new" and by "don't see an email option" you mean that you cannot find the email property in the Visual Studio intellisense drop-down. If this assumption is correct, then what you see is completely normal, because the Appointment class does not have an Email property. It is your MySched class that has the Email property. So in order to see the Email property you will need to create instances of your custom MySched class.

IEvent appointment = new MySched(/* set some of the parameters here */);
appointment.Email = "email@acme.com";
this.radScheduler1.Appointments.Add(appointment);

Regarding your second combo box in the appointment edit dialog. In the OnLoad method of your application form you can create a collection of the items that you want to load in that second combo. Then you have to pass that collection to your custom appointment edit dialog. You can do that using the constructor or a property. And finally in the OnLoad method of your appointment edit dialog you can fill the second combo box using the data from that collection.

Do not hesitate to write again if you have more questions.

Kind regards,
Jordan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jeremy Murtishaw
Top achievements
Rank 1
answered on 16 Aug 2009, 04:44 PM
Thank you for your reply.  Your answer to part 1 fixed my issue.

Regarding Part 2, can you give me a code example with how to create a new Property on my custom Appointment dialog?  It should be a collection of items.  Also, if you would please include an example of how to populate the combobox in OnLoad of that form too.

Thanks
0
Accepted
Deyan
Telerik team
answered on 19 Aug 2009, 12:22 PM
Hi Jeremy,

Thanks for writing back and for your question.

I am not quite sure that I understand you correctly but I guess you would like to add a new property in the class that represents your custom Edit Appointment Dialog form. Take a look at the following code snippet:

public partial class MyCustomAppointmentDialog : EditAppointmentDialog  
    {  
        private ICollection items;  
 
        public MyCustomAppointmentDialog()  
        {  
            InitializeComponent();  
        }  
 
          
 
        public ICollection Items  
        {  
            get 
            {  
                return this.items;  
            }  
            set 
            {  
                this.items = value;   
            }  
        }  
 
        protected override void OnLoad(EventArgs e)  
        {  
            base.OnLoad(e);  
            this.radComboBox1.DataSource = this.items;  
        }  
    } 

As you can see I have created a simple Form and have changed its base class in EditAppointmentDialog. I have defined an Items property which is of type ICollection since I do not know what type of collection you are using to hold your items (you can change this type according to your preferences). I can access this property and use it to set the collection that holds the items. This should happen before the form is shown so that you make sure that in the OnLoad event where I bind my additional RadComboBox (the one that you manually put in your custom dialog form) the Items are already available.

I hope this is helpful. Do not hesitate to write back in case I misunderstood your case or you have any further questions.

Sincerely yours,
Deyan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jeremy Murtishaw
Top achievements
Rank 1
answered on 19 Aug 2009, 06:01 PM
This is very helpful.  Should I set the Items collection in:
private void radScheduler_AppointmentEditDialogShowing(object sender, AppointmentEditDialogShowingEventArgs e)
?

How would I set the items collection property from the original form?

I thought maybe I would see this.radScheduler.Items but I don't.

Thanks again.
0
Jeremy Murtishaw
Top achievements
Rank 1
answered on 19 Aug 2009, 09:53 PM
I see it now...

this.appointmentDialog.Items = myItems;

Thanks again.
Tags
Scheduler and Reminder
Asked by
Jeremy Murtishaw
Top achievements
Rank 1
Answers by
Jordan
Telerik team
Jeremy Murtishaw
Top achievements
Rank 1
Deyan
Telerik team
Share this question
or