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

RAD Calendar

1 Answer 113 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Pelumi
Top achievements
Rank 1
Pelumi asked on 04 Feb 2015, 05:33 PM
I am pretty new to RadCalendar.
How can I bind RadCalendar to a local database?
The aim is for the RadCalendar to show the Database inputs.


Any Help will be appreciated 

Regards

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 09 Feb 2015, 12:26 PM
Hello Pelumi,

Thank you for writing.

RadCalendar offers FocusedDate property which indicates the current selection. If I understand your requirement correctly, you are trying to bind a DateTime property coming from the data base to the RadCalendar. For this purpose you can use simple data binding. Here is a sample code snippet demonstrating how to bind the RadCalendar.FocusedDate property to the custom Item.CreatedOn property. When you update the custom object's property, the RadCalendar.FocusedDate property will be refreshed:
public Form1()
{
    InitializeComponent();
    Item item = new Item(123,"Custom Item", new DateTime(1990,04,25));
    this.radPropertyGrid1.SelectedObject = item;
     
    this.radCalendar1.DataBindings.Add("FocusedDate", item, "CreatedOn",
        true, DataSourceUpdateMode.OnPropertyChanged);
}
 
public class Item : System.ComponentModel.INotifyPropertyChanged
{
    private int id;
    private string name;
    private DateTime createdOn;
 
    public Item(int id, string name, DateTime createdOn)
    {
        this.id = id;
        this.name = name;
        this.createdOn = createdOn;
    }
 
    public event PropertyChangedEventHandler PropertyChanged;
     
    protected virtual void OnPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
 
    public int Id
    {
        get
        {
            return this.id;
        }
        set
        {
            this.id = value;
            OnPropertyChanged("Id");
        }
    }
 
    public string Name
    {
        get
        {
            return this.name;
        }
        set
        {
            this.name = value;
            OnPropertyChanged("Name");
        }
    }
     
    public DateTime CreatedOn
    {
        get
        {
            return this.createdOn;
        }
        set
        {
            this.createdOn = value;
            OnPropertyChanged("CreatedOn");
        }
    }
}

If it is not the exact requirement, please give us same more details about the exact scenario that you are trying to achieve. Thus, we would be able to assist you further.

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

Regards,
Dess
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Pelumi
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or