SPREAD for WPF 3.0J - GcSpreadSheet
選択不可日
SPREAD for WPF 3.0J - GcSpreadSheet > 開発者ガイド > セル型 > 日付時刻型セル > ドロップダウンカレンダー > 選択不可日

ユーザーに対して、ドロップダウン カレンダーの指定した日付を選択できないように設定できます。

選択不可日

選択不可日は、日付時刻型セルの BlackoutDates プロパティに設定します。

次のサンプルコードは1列目を日付時刻型セルに設定し、ドロップダウン カレンダーに選択不可日を設定します。

XAML
コードのコピー
<gss:GcSpreadSheet x:Name="GcSpreadSheet">
    <gss:GcSpreadSheet.Sheets>
        <gss:SheetInfo RowCount="10" ColumnCount="5">
            <gss:SheetInfo.Columns>
                <gss:ColumnInfo Width="200">
                    <gss:ColumnInfo.CellType>
                        <gss_CellType:DateTimeCellType>
                            <gss_CellType:DateTimeCellType.BlackoutDates>
                                <gss:CalendarDateRange Start="2020/2/20" End="2020/3/10"/>
                            </gss_CellType:DateTimeCellType.BlackoutDates>
                        </gss_CellType:DateTimeCellType>
                    </gss:ColumnInfo.CellType>
                </gss:ColumnInfo>
            </gss:SheetInfo.Columns>
        </gss:SheetInfo>
    </gss:GcSpreadSheet.Sheets>
</gss:GcSpreadSheet>        
メモ:セル型をXAMLで使用するには、次のような名前空間を宣言します。
xmlns:gss_CellType="clr-namespace:GrapeCity.Wpf.SpreadSheet.CellType;assembly=GrapeCity.Wpf.SpreadSheet.CellType"

また、選択不可日のコレクションを表す BlackoutDatesCollectionAddDatesInPast メソッドにより、過去の日付をすべて選択不可に設定できます。

次のサンプルコードは日付時刻型セルのドロップダウン カレンダーの過去の日付をすべて選択不可に設定します。

C#
コードのコピー
DateTimeCellType dt = new DateTimeCellType();
dt.BlackoutDates.AddDatesInPast();
GcSpreadSheet.Workbook.ActiveSheet.Columns[0].CellType = dt;
GcSpreadSheet.Workbook.ActiveSheet.Columns[0].ColumnWidth = 250;
                
Visual Basic
コードのコピー
Dim dt As DateTimeCellType = New DateTimeCellType()
dt.BlackoutDates.AddDatesInPast()
GcSpreadSheet.Workbook.ActiveSheet.Columns(0).CellType = dt
GcSpreadSheet.Workbook.ActiveSheet.Columns(0).ColumnWidth = 250
                
関連トピック