Gtk.Calendar Class
Display a Calendar and/or allow the user to select a date.

See Also: Calendar Members


public class Calendar : Widget


With a Calendar widget, dates are presented to the user one month at a time. Additional information and decorations can be added to the Calendar by using the Gtk.CalendarDisplayOptions enumeration with the Gtk.DisplayOptions property.

Days can be highlighted on the Calendar with Calendar.MarkDay or Calendar.SelectDay.

The following example shows a method that creates a simple Calendar displaying day names, headings and week numbers.

C# Example

// Create a calendar with some simple display options
public Calendar CreateCalendar ()
    Calendar cal = new Calendar ();
    cal.DisplayOptions = CalendarDisplayOptions.ShowHeading  | 
                         CalendarDisplayOptions.ShowDayNames | 
    cal.DaySelected += new EventHandler(HandleDaySelected);
    return cal;

The following example shows a typical event handler that outputs the date when one is selected.

C# Example

// Typical event handler for capturing the selected date
void HandleDaySelected (object obj, EventArgs args)
    Calendar activatedCalendar = (Calendar) obj;
    Console.WriteLine (activatedCalendar.GetDate ().ToString ("yyyy/MM/dd"));


Namespace: Gtk
Assembly: gtk-sharp (in gtk-sharp.dll)
Assembly Versions: