1

我正在尝试修改月历,但在将用户控件添加到表单之前,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);
}
4

1 回答 1

0

您可以使用以下代码来解决此问题:

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);
}
于 2015-08-19T13:52:47.537 回答