Hi, the outlook look and feel calendar control for windows forms is great and would be perfect in my project, I fixed some of the bugs by using this forum however, does anyone know how to load appointments from a database into it?
I would ideally like to use a database with fields: DateStart, DateEnd, Description, I'm using datasource in visual studio to connect to the database, anyhelp would be great, i'm fairly new to C#
Below is the code sample for the event add button click, can this be used as a form load event but load entries from a database instead?
private
void addItem_Click(object sender, EventArgs e)
{
try
{
DateTime startTime = new DateTime(datePicker.Value.Year, datePicker.Value.Month, datePicker.Value.Day, (int)this.startHour.Value, Int32.Parse(this.startMinute.Text), 0);
DateTime endTime = new DateTime(datePicker1.Value.Year, datePicker1.Value.Month, datePicker1.Value.Day, (int)this.endHour.Value, Int32.Parse(this.endMinute.Text), 0);
if (endTime.CompareTo(startTime) <= 0)
{
MessageBox.Show("End time is either same as or before the start time. Please check the times");
return;
}
if (this.descriptionTextBox.Text == null || this.descriptionTextBox.Text.Trim() == String.Empty)
{
MessageBox.Show("Please enter some description of this item");
return;
}
this.calendar1.CalendarItems.Add(new CalendarItem(startTime, endTime, this.descriptionTextBox.Text.Trim(), this.tentativeCheckBox.Checked));
this.calendar1.InitializeDisplay();
}
catch (Exception ex)
{
Trace.WriteLine(ex.ToString());
}
}
Thanks
Mike