Skip to main content Skip to footer

How to Set C1DateEdit Focus to Day instead of Month

When the C1DateEdit control gets focus, it defaults to using the month. When you click the up or down arrow, it changes the month, but some users may want the up and down arrows to change only the "days" value instead. To accomplish this, please utilize the following code inside the UpDownButtonClick event for the C1DateEdit control:

private void c1DateEdit1_UpDownButtonClick(object sender, C1.Win.C1Input.UpDownButtonClickEventArgs e)
{
    var dateEdit = (C1.Win.Calendar.C1DateEdit)sender;
    var value = dateEdit.Value;
    if (value is DateTime dateTime)
    {
        if (e.Delta > 0)
        {
            for (int i = 0; i < e.Delta; i++)
            {
                dateEdit.Value = dateTime.AddDays(e.Delta);
            }
        }
        else
        {
            for (int i = 0; i < -e.Delta; i++)
            {
                dateEdit.Value = dateTime.AddDays(e.Delta);
            }
        }
        e.Done = true;
    }
}

Hunter Haaf