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
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.)
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); } }
I don't have a direct access to a calendar object , i only have a DateColumn in a UltraWinGrid and when i click on this DateColumn a month calendar is displayed.
But i don't know if i can customize this calendar.
Thank you for your answer tbetts . I'm using a C# Infragistics.Win.UltraWinGrid wich contains a UltraGridColum representing a date :
Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn2 = new = Infragistics.Win.UltraWinGrid.UltraGridColumn("_transactionInDate");
ultraGridColumn2.Format = "d";
Since this was posted into the general discussion forum I'm a little confused at what controls you are using? I'll assume win forms, so if it's not, just be more specific in your next reply about the situation.
If you have a WinGrid that is using a WinCalendarCombo, you can use the WinCalendarCombo along with the WinCalendarInfo control that will let you further control what the users see and interact with date wise.
In other words, you can completely hide or disable any dates, days, weeks, months, or years that you want with the WinCalendarInfo control.