UserControl for MonthCalendar
本文关键字:MonthCalendar for UserControl | 更新日期: 2023-09-27 18:08:48
我试图修改月历,但在添加用户控件到表单之前,VS冻结。问题是在无限循环中,但我找不到错误。请帮助
private void SetDayBoxSize()
{
int bottom = this.Height;
while (HitTest(1, dayTop).HitArea != HitArea.Date &&
HitTest(1, dayTop).HitArea != HitArea.PrevMonthDate) dayTop++;
while (HitTest(1, bottom).HitArea != HitArea.Date &&
HitTest(1, bottom).HitArea != HitArea.NextMonthDate) bottom--;
dayBox = new Rectangle();
dayBox.Size = new Size(this.Width / 7, (bottom - dayTop) / 6);
}
您可以使用下面的代码来解决这个问题:
private void SetDayBoxSize()
{
int bottom = this.Height;
while (HitTest(25, dayTop).HitArea != HitArea.Date &&
HitTest(25, dayTop).HitArea != HitArea.PrevMonthDate) dayTop++;
while (HitTest(25, bottom).HitArea != HitArea.Date &&
HitTest(25, bottom).HitArea != HitArea.NextMonthDate) bottom--;
dayBox = new Rectangle();
dayBox.Size = new Size(this.Width / 7, (bottom - dayTop) / 6);
}