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
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); } }
If you set the editor component of that date column to the WinCalendarCombo instead of using the embedded DateTimeEditor, it's more compatible with WinCalendarInfo and makes things a lot easier to avoid mad scientist style.
You can disable anything you want in the calendar drop down just by doing things like:
ultraCalendarInfo1.DaysOfWeek[DayOfWeek.Sunday].Enabled = false; ultraCalendarInfo1.DaysOfWeek[DayOfWeek.Saturday].Enabled = false; ultraCalendarInfo1.MonthsOfYear[Infragistics.Win.UltraWinSchedule.YearMonthEnum.December].Enabled = false; etc...
(To use the WinCalendarCombo in your grid, just drop it on the form some place, and set the visible property to false. Then you can use set the EditorComponent of the date value column you're wanting to use it with.)