SelectedDatesCollection.Clear メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SelectedDatesCollection.Clear メソッドの意味・解説 

SelectedDatesCollection.Clear メソッド

コレクションからすべての System.DateTime オブジェクト削除します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

解説解説

このメソッド使用して、SelectedDatesCollection コレクションからすべてのSystem.DateTime オブジェクト削除しCount プロパティに 0 を設定します

使用例使用例

Clear メソッド使用してSelectedDatesCollection コレクションからすべての System.DateTime オブジェクト削除し新しSystem.DateTime オブジェクト置き換える方法次のコード例示します

<%@ Page Language="VB" AutoEventWireup="True"
 %>

<html>
<head>
 
   <script runat="server">

      Sub Page_Load(sender As Object,
 e As EventArgs)

         ' Initialize the VisibleDate property with today's date when
         ' the page is first loaded.
         If Not IsPostBack Then

            Calendar1.VisibleDate = Calendar1.TodaysDate

         End If

      End Sub
     
      Sub Button_Click(sender As Object,
 e As EventArgs) 

         ' This method demonstrates how to select noncontiguous dates
 
         ' in the calendar. 
  
         ' Get the month, day, and year of the date contained in the
 
         ' VisibleDate property.
         Dim CurrentMonth As Integer
 = Calendar1.VisibleDate.Month
         Dim CurrentYear As Integer
 = Calendar1.VisibleDate.Year
   
         ' Clear all selected dates.
         Calendar1.SelectedDates.Clear()
   
         ' Iterate through the current month and add all Wednesdays
 
         ' to the collection.
         Dim i As Integer

         For i = 1 To System.DateTime.DaysInMonth(CurrentYear,
 CurrentMonth)

            Dim CurrentDate As DateTime = _
                New DateTime(CurrentYear, CurrentMonth, i)

            If CurrentDate.DayOfWeek = DayOfWeek.Wednesday Then
            
                Calendar1.SelectedDates.Add(CurrentDate)
            
            End If

         Next i
 
         ' Display the number of items selected.
         Message.Text = "Selection Count = " &
 _
             Calendar1.SelectedDates.Count.ToString()
 
      End Sub
 
      Sub Selection_Change(sender As Object,
 e As EventArgs) 

         ' Display the number of items selected.
         Message.Text = "Selection Count = " &
 _
             Calendar1.SelectedDates.Count.ToString()

      End Sub
 
   </script>
 
</head>     
<body>
 
   <form runat="server">

      <h3>SelectedDatesCollection Add Example </h3>

      Click the button to select all Wednesdays
 in the month.

      <br><br>
 
      <asp:Calendar ID="Calendar1" runat="server"
  
           SelectionMode="DayWeekMonth" 
           OnSelectionChanged="Selection_Change" />
 
      <hr>
 
      <asp:Button id="SubmitButton"
           Text="Select All Weds in Month" 
           OnClick="Button_Click"  
           runat=server  /> 

      <br>
 
      <asp:Label id="Message" 
           runat="server" />

   </form>

</body>
</html>
 
<%@ Page Language="C#" AutoEventWireup="True" %>

<html>
<head>
 
   <script runat="server">

      void Page_Load(Object sender, EventArgs e)
      {

         // Initialize the VisibleDate property with today's date when
         // the page is first loaded.
         if(!IsPostBack)
         {

            Calendar1.VisibleDate = Calendar1.TodaysDate;

         }

      }
     
      void Button_Click(Object sender, EventArgs e) 
      {

         // This method demonstrates how to select noncontiguous dates
 
         // in the calendar. 
  
         // Get the month and year of the date contained in the 
         // VisibleDate property.
         int CurrentMonth = Calendar1.VisibleDate.Month;
         int CurrentYear = Calendar1.VisibleDate.Year;
   
         // Clear all selected dates.
         Calendar1.SelectedDates.Clear();
   
         // Iterate through the current month and add all Wednesdays
 
         // to the collection.
         for (int i = 1; 
             i <= System.DateTime.DaysInMonth(CurrentYear, CurrentMonth);
              i++)
         {

            DateTime CurrentDate = new DateTime(CurrentYear, CurrentMonth,
 i);

            if (CurrentDate.DayOfWeek == DayOfWeek.Wednesday)
            {
               Calendar1.SelectedDates.Add(CurrentDate);
            }

         }
 
         // Display the number of items selected.
         Message.Text = "Selection Count = " + 
             Calendar1.SelectedDates.Count.ToString();
 
      }
 
      void Selection_Change(Object sender, EventArgs e) 
      {

         // Display the number of items selected.
         Message.Text = "Selection Count = " + 
             Calendar1.SelectedDates.Count.ToString();

      }
 
   </script>
 
</head>     
<body>
 
   <form runat="server">

      <h3>SelectedDatesCollection Add Example </h3>

      Click the button to select all Wednesdays in the month.

      <br><br>
 
      <asp:Calendar ID="Calendar1" runat="server"  
           SelectionMode="DayWeekMonth" 
           OnSelectionChanged="Selection_Change" />
 
      <hr>
 
      <asp:Button id="SubmitButton"
           Text="Select All Weds in Month" 
           OnClick="Button_Click"  
           runat=server  /> 

      <br>
 
      <asp:Label id="Message" 
           runat="server" />

   </form>

</body>
</html>
 
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SelectedDatesCollection クラス
SelectedDatesCollection メンバ
System.Web.UI.WebControls 名前空間
System.DateTime
Count



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

SelectedDatesCollection.Clear メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SelectedDatesCollection.Clear メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS