我想在Pabo日历中显示当前日期,但是只有一个只读属性。
如何设置当前日期?
namespace Pabo.Calendar
{
[DefaultEvent("MonthChanged")]
[DefaultProperty("Name")]
[Designer(typeof(MonthCalendarDesigner))]
[ToolboxBitmap(typeof(MonthCalendar), "Pabo.Calendar.MonthCalendar.bmp")]
[ToolboxItem(true)]
public class MonthCalendar : Control
{
public WeekCallBack WeeknumberCallBack;
public MonthCalendar();
[Category("Behavior")]
[Description("")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ActiveMonth ActiveMonth { get; }
[Category("Behavior")]
[DefaultValue(0)]
[Description("First day of week.")]
[RefreshProperties(RefreshProperties.All)]
[TypeConverter(typeof(FirstDayOfWeekConverter))]
public int FirstDayOfWeek { get; set; }
}
}
我对Pabo.Calendar
控件不是很熟悉,但是看起来您可以只更新从Month
属性返回的对象的Year
或ActiveMonth
属性。这样的事情应该起作用:
// This code example assumes you have an instance of the
// MonthCalendar object that is called `myMonthCalendar`.
var today = DateTime.Today;
myMonthCalendar.ActiveMonth.Year = today.Year;
myMonthCalendar.ActiveMonth.Month = today.Month;