HeaderPane
Main
Hide
Share Link
Print

Hit Testing

The HitTest method returns what is at a location of a control, in pixels relative to the control's client area (HitTest, HitTest). Its return value tells what is at the location; for a calendar, its Date parameter returns the date there, or Null. The coordinates of the mouse events (MouseDown, MouseUp, MouseMove) can be passed as they are.

Fields

For an SftDate control, HitTest returns one of these values (see SftDateFieldHitConstants):

ValueLocation
fieldHitSftDateNowhereOutside the field.
fieldHitSftDateSegmentA part of the value that can be edited.
fieldHitSftDateTextThe text area outside a part, the text box of a field with free-form editing, or the text area of an empty field.
fieldHitSftDateCheckBoxThe check box.
fieldHitSftDateClearButtonThe Clear button.
fieldHitSftDateDropDownButtonThe dropdown button.
fieldHitSftDateUpButton, fieldHitSftDateDownButtonThe up and down buttons.

The Date parameter returns Null for a field. The dropdown is a window of its own and is not part of the field's client area; points in the dropdown return fieldHitSftDateNowhere.

Calendars

For an SftCalendar control, HitTest returns one of these values (see SftDateCalendarHitConstants):

ValueLocation
calHitSftDateNowhereOutside the calendar.
calHitSftDateBackgroundThe background, outside the other parts.
calHitSftDateTitleThe title of a month, a year, a decade or a century; Date is the first date of the period.
calHitSftDatePreviousButton, calHitSftDateNextButtonThe previous and next buttons.
calHitSftDateDayOfWeekThe name of a day of the week.
calHitSftDateWeekNumberA week number; Date is the first date of the week's row.
calHitSftDateDayA day of a month; Date is the day.
calHitSftDateTrailingDayA day of the previous or next month; Date is the day.
calHitSftDatePeriodA month, a year or a decade in the larger views; Date is the first date of the period.
calHitSftDateTodayButton, calHitSftDateClearButtonThe Today and Clear buttons.

This example shows a context menu (menuDay, a ContextMenuStrip of the form) when the user right-clicks a day:

private void sftCalendar1_MouseUpEvent(object sender, AxSftDateLib20._ISftCalendarEvents_MouseUpEvent e) {
    if (e.button != (short)SftControlButtonConstants.constSftControlRightButton)
        return;
    object date;
    if (sftCalendar1.HitTest(e.xPos, e.yPos, out date) == SftDateCalendarHitConstants.calHitSftDateDay) {
        menuDay.Tag = date;                     // the day the menu's commands apply to
        menuDay.Show(sftCalendar1, new Point(e.xPos, e.yPos));
    }
}

Last Updated 11/29/2026 - (email)
© 2026 Softel vdm, Inc.