【发布时间】:2017-02-05 19:53:18
【问题描述】:
我正在尝试在我的 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();
提前致谢!
【问题讨论】:
-
您的目标是什么:Winforms、WPF、ASP..? 始终正确标记您的问题!
-
您的代码看起来不错。很可能你的日期不是。但是,当然,一直初始化数组是没有意义的。而是使用 List
,在循环之外声明它并在循环之后将其添加为.ToaRRay()! -
我一直在尝试这种方式,但似乎BoldedDates 属性不起作用。无论如何,感谢您的宝贵时间。
-
嗯,我试过了,它确实在这里工作。