Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > Outlook Look and feel calendar control for windows forms
 

Outlook Look and feel calendar control for windows forms

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

  • Edited byDelvotti Wednesday, June 10, 2009 12:35 PM
  • Changed TypeDelvotti Wednesday, June 10, 2009 11:12 AM
  • Edited byDelvotti Wednesday, June 10, 2009 12:32 PM
  •  
Delvotti  Wednesday, June 10, 2009 10:48 AM

Hi Delvotti,

I have read your code. Here is something I confused. DatePicker, Calendar, CalendarItems, all these are WPF controls. Do you develop a WPF application?

Sincerely,
Kira Qian


Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Friday, June 12, 2009 2:45 AM

Hi,

I'm developing a c# windows form application, i was hoping to use the calendar control within it.

The code above works fine to add apointments manually, how ever i would like to load stored appointments from my database on form load.

Delvotti  Friday, June 12, 2009 8:12 AM

You can use google to search for other answers

Custom Search

More Threads

• User Submitted Improvements
• how does issue vision "redraw" screen when spitter is dragged ?
• help!!!
• XPander nesting
• Whenever I try to introduce an animal i get a stack overflow in terrarium.exe
• OTP folder in win xp
• Please help big newbie!
• Length of Turn - Microseconds
• Anything WoW you lately
• Terrarium 1.2 Server -> Peercount fix