Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
135
Disable all Saturday / Sunday on the dynamic calendar
posted

Hey all,

I have a Summit.Framework.View.DateColumn in a SerializedDataSpreadSheetControl :

this._transactionInDate = new Summit.Framework.View.DateColumn();

Is there a way to disable all Saturday / Sunday on the dynamic calendar which is displayed ?

 

Thank you

Vianney

Parents
  • 3707
    posted

    Here's the mad scientist way I used WinCalendarInfo with the embedded DateTimeEditor on WinGrid.

    private void frmMain_Load(object sender, EventArgs e)
    {
       this.ultraCalendarInfo1.DaysOfWeek[DayOfWeek.Saturday].IsWorkDay = false; //Disable Saturday
       this.ultraCalendarInfo1.DaysOfWeek[DayOfWeek.Sunday].IsWorkDay = false; //Disable Sunday
    }
    private void ultraGrid1_MouseDown(object sender, MouseEventArgs e)
    {
       UIElement element = ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(e.Location);
       if (element == null || element.Parent == null)
          return;
       if (element.Parent is DateTimeEditorUIElement)
       {
          DateTimeEditorUIElement dateElement = (DateTimeEditorUIElement)element.Parent;
          DateTimeEditor dateControl = (DateTimeEditor)dateElement.Editor;
          dateControl.ValueChanged += dateControl_ValueChanged;
       }
    }
    void dateControl_ValueChanged(object sender, EventArgs e)
    {
       DateTimeEditor dateControl = (DateTimeEditor)sender;
       DateTime selectedDate = DateTime.Parse(dateControl.Value.ToString());
       dateControl.ValueChanged -= dateControl_ValueChanged;
       if (ultraCalendarInfo1.IsWorkDay(selectedDate))
       {
           //Nothing, changed value allowed
       }
       else
       {
           ultraGrid1.ActiveCell.CancelUpdate();
           MessageBox.Show("Saturday and Sunday selections are not allowed.", 
              "Date Selection", MessageBoxButtons.OK, MessageBoxIcon.Stop);
       }
    }

Reply Children
No Data