我正试着在我的MonthCalendar上加粗一些日期。我确实从我的文件名中完美地获得了所有的日期,但似乎就是不能加粗单元格。有没有人能解释一下我做错了什么?下面是我在Form_Load函数上使用的代码:
MonthCalendar c = new MonthCalendar();
lbl_date.Text = c.TodayDate.ToString("dd/MM/yyyy");
loadEventDisplay();
string dirPath = @"E:\Calendar\";
List<string> files = new List<string>(Directory.EnumerateFiles(dirPath));
foreach (var file in files)
{
string year = file.Substring(18, 4);
string month = file.Substring(15, 2);
string day = file.Substring(12, 2);
DateTime[] dt = new DateTime[]
{
new DateTime(Int32.Parse(year), Int32.Parse(month), Int32.Parse(day))
};
// The date format I am using on that line is actually the same that works with the graphic interface
c.AddBoldedDate(DateTime.Parse(day+"/"+month+"/"+year));
c.UpdateBoldedDates();提前谢谢!
发布于 2017-02-06 04:11:10
您可能只想使用月份日历控件
下面是一个可以提供帮助的代码:
DateTime[] myDates = {myDate1, myDate2};
calendar.BoldedDates = myDates;希望这能有所帮助。请参阅Here
https://stackoverflow.com/questions/42056539
复制相似问题