PowerTools InputMan for ASP.NET 8.0J
Add(DateTimeEx) メソッド
使用例 

選択日付
(GrapeCity.Web.Input.Core.DateTimeEx 型)
SelectionCollectionコレクションの末尾に選択日付を追加します。
構文
Public Overloads Function Add( _
   ByVal date As DateTimeEx _
) As Integer
public int Add( 
   DateTimeEx date
)

パラメータ

date
選択日付
(GrapeCity.Web.Input.Core.DateTimeEx 型)

戻り値の型

選択日付の総数を示す整数値。
解説
複数の選択日付を一度に登録する場合は、AddRangeメソッドを使用します。インデックスを指定して追加する場合は、Insert(Int32,Object)メソッドを使ってください。また、選択日付の削除は、Remove(Object)RemoveAt、またはClearのいずれかのメソッドを使用します。
使用例
次のサンプルコードは、Addメソッドを使ってカレント日を含む月のすべての日付を選択する方法を示します。
Imports GrapeCity.Web.Input.Core
Imports GrapeCity.Web.IMCalendar

' 日付の選択モードを複数選択に設定します。
GcCalendar1.SelectionMode = SelectionMode.MultiSimple
GcCalendar1.MaxSelectionCount = 31
' カレントの年を取得します。
Dim aYear As Integer = GcCalendar1.FocusDate.Year
' カレントの月を取得します。
Dim aMonth As Integer = GcCalendar1.FocusDate.Month
' 翌月1日の日付を取得します。
Dim firstDay As DateTime = New DateTime(aYear, aMonth + 1, 1)
' カレント月の最終日を取得します。
Dim maxDay As Integer = firstDay.AddDays(-1).Day
' カレント月の1日から最終日までをコレクションに追加します。
Dim i As Integer
For i = 1 To maxDay
    Dim dt As DateTime = New DateTime(aYear, aMonth, i)
    GcCalendar1.Selections.Add(New DateTimeEx(dt))
Next i
using GrapeCity.Web.Input.Core;
using GrapeCity.Web.IMCalendar;

// 日付の選択モードを複数選択に設定します。
GcCalendar1.SelectionMode = SelectionMode.MultiSimple;
GcCalendar1.MaxSelectionCount = 31;
// カレントの年を取得します。
int aYear = GcCalendar1.FocusDate.Year;
// カレントの月を取得します。
int aMonth = GcCalendar1.FocusDate.Month;
// 翌月1日の日付を取得します。
DateTime firstDay = new DateTime(aYear,aMonth + 1,1);
// カレント月の最終日を取得します。
int maxDay = firstDay.AddDays(-1).Day;
// カレント月の1日から最終日までをコレクションに追加します。
for (int i=1;i <= maxDay;i++)
{
    DateTime dt = new DateTime(aYear, aMonth, i);
    GcCalendar1.Selections.Add(new DateTimeEx(dt));
}
参照

SelectionCollection クラス
SelectionCollection メンバ
オーバーロード一覧

 

 


© 2005-2015 GrapeCity inc. All rights reserved.