[C#] MonthCalendar 요일 클릭하기
/// <summary>
/// 주어진 위치가 어떤 요일인지 구함
/// </summary>
/// <param name="xCursor">커서의 X좌표</param>
/// <returns>
/// [요일]
/// - 0 : 일요일
/// - 1 : 월요일
/// - 2 : 화요일
/// - 3 : 수요일
/// - 4 : 목요일
/// - 5 : 금요일
/// - 6 : 토요일
/// </returns>
public int GetWeek(int xCursor)
{
int wi = (this.Width - (this.DefaultMargin.Horizontal)) / this.CalendarDimensions.Width;
this.CellWidth = wi / 7;
for (int k = 0; k < this.CalendarDimensions.Width; ++k)
{
for (int i = 0; i < 7; ++i)
{
int left = (this.CellWidth * i) + wi * k;
int right = (this.CellWidth * (i + 1)) + wi * k;
if (left < xCursor && xCursor < right)
return i;
}
}
return -1;
}
예제)