Suggérer une traduction
 
Suggestions d'autres utilisateurs :

progress indicator
Aucune autre suggestion.
Cliquez pour évaluer et commenter
MSDN
MSDN Library
Développement .NET
.NET Framework 4
Espaces de noms System.Web
System.Web.UI.WebControls
Réduire tout/Développer tout Réduire tout
Affichage du contenu :  côte à côteAffichage du contenu : côte à côte
.NET Framework Class Library
SelectedDatesCollection Class

Encapsulates a collection of System..::.DateTime objects that represent the selected dates in a Calendar control. This class cannot be inherited.

System..::.Object
  System.Web.UI.WebControls..::.SelectedDatesCollection

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)
Visual Basic
Public NotInheritable Class SelectedDatesCollection _
    Implements ICollection, IEnumerable
C#
public sealed class SelectedDatesCollection : ICollection, 
    IEnumerable
Visual C++
public ref class SelectedDatesCollection sealed : ICollection, 
    IEnumerable
F#
[<Sealed>]
type SelectedDatesCollection =  
    class
        interface ICollection
        interface IEnumerable
    end

The SelectedDatesCollection type exposes the following members.

  NameDescription
Public methodSelectedDatesCollectionInitializes a new instance of the SelectedDatesCollection class with the specified date list.
Top
  NameDescription
Public propertyCountGets the number of System..::.DateTime objects in the SelectedDatesCollection collection.
Public propertyIsReadOnlyGets a value indicating whether the SelectedDatesCollection collection is read-only.
Public propertyIsSynchronizedGets a value indicating whether access to the SelectedDatesCollection collection is synchronized (thread safe).
Public propertyItemGets a System..::.DateTime object at the specified index in the SelectedDatesCollection collection.
Public propertySyncRootGets the object that can be used to synchronize access to the SelectedDatesCollection collection.
Top
  NameDescription
Public methodAddAppends the specified System..::.DateTime object to the end of the SelectedDatesCollection collection.
Public methodClearRemoves all System..::.DateTime objects from the collection.
Public methodContainsReturns a value indicating whether the SelectedDatesCollection collection contains the specified System..::.DateTime object.
Public methodCopyToCopies the items from the SelectedDatesCollection collection to the specified System..::.Array, starting with the specified index.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEnumeratorReturns an System.Collections..::.IEnumerator-implemented object that contains all System..::.DateTime objects within the SelectedDatesCollection collection.
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodRemoveRemoves the specified System..::.DateTime object from the SelectedDatesCollection collection.
Public methodSelectRangeAdds the specified range of dates to the SelectedDatesCollection collection.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top
  NameDescription
Public Extension MethodAsParallelEnables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension MethodAsQueryableConverts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension MethodCast<(Of <(TResult>)>)Converts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension MethodOfType<(Of <(TResult>)>)Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top

Use this class to programmatically manage a collection of System..::.DateTime objects that represent the selected dates in a Calendar control. This class is commonly used to add or remove dates from the collection.

This collection stores only whole dates. The time portion of each System..::.DateTime is removed. The dates are stored in ascending order. If there are duplicate dates, only one date is stored in the collection.

The following code example demonstrates how to programmatically use the SelectedDatesCollection class to select dates in the Calendar control.

Visual Basic
<%@ Page Language="VB"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

    DisplayCalendar.VisibleDate = DisplayCalendar.TodaysDate

  End Sub

  Sub SelectButton_Click(ByVal sender As Object, ByVal e As EventArgs)

    Dim current_day As Integer = DisplayCalendar.VisibleDate.Day
    Dim current_month As Integer = DisplayCalendar.VisibleDate.Month
    Dim current_year As Integer = DisplayCalendar.VisibleDate.Year

    DisplayCalendar.SelectedDates.Clear()

    ' Iterate through the current month and add all Wednesdays to the 
    ' SelectedDates collection of the Calendar control.
    Dim i As Integer
    For i = 1 To System.DateTime.DaysInMonth(current_year, current_month)

      Dim currentDate As New DateTime(current_year, current_month, i)
      If currentDate.DayOfWeek = DayOfWeek.Wednesday Then

        DisplayCalendar.SelectedDates.Add(currentDate)

      End If

    Next

    MessageLabel.Text = "Selection Count = " + DisplayCalendar.SelectedDates.Count.ToString()

  End Sub

  Sub DisplayCalendar_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)

    MessageLabel.Text = "Selection Count = " & DisplayCalendar.SelectedDates.Count.ToString()

  End Sub

</script> 

<html  >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <asp:calendar id="DisplayCalendar" runat="server"  
        selectionmode="DayWeekMonth" 
        onselectionchanged="DisplayCalendar_SelectionChanged" />

      <hr />

      <asp:button id="SelectButton"
        text="Select All Weds in Month" 
        onclick="SelectButton_Click"  
        runat="server"/> 

      <br/>

      <asp:label id="MessageLabel" 
        runat="server" />

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void Page_Load(Object sender, EventArgs e) 
  {
    DisplayCalendar.VisibleDate = DisplayCalendar.TodaysDate;
  }

  void SelectButton_Click(Object sender, EventArgs e) 
  {

    int current_day = DisplayCalendar.VisibleDate.Day;
    int current_month = DisplayCalendar.VisibleDate.Month;
    int current_year = DisplayCalendar.VisibleDate.Year;

    DisplayCalendar.SelectedDates.Clear();

    // Iterate through the current month and add all Wednesdays to the 
    // SelectedDates collection of the Calendar control.
    for (int i = 1; i <= System.DateTime.DaysInMonth(current_year, current_month); i++)
    {
       DateTime currentDate = new DateTime(current_year, current_month, i);
       if (currentDate.DayOfWeek == DayOfWeek.Wednesday)
       {
         DisplayCalendar.SelectedDates.Add(currentDate);
       }
    }

     MessageLabel.Text = "Selection Count = " + DisplayCalendar.SelectedDates.Count.ToString();

  }

  void DisplayCalendar_SelectionChanged(Object sender, EventArgs e) 
  {
    MessageLabel.Text = "Selection Count = " + DisplayCalendar.SelectedDates.Count.ToString();
  }

</script> 

<html  >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <asp:calendar id="DisplayCalendar" runat="server"  
        selectionmode="DayWeekMonth" 
        onselectionchanged="DisplayCalendar_SelectionChanged" />

      <hr />

      <asp:button id="SelectButton"
        text="Select All Weds in Month" 
        onclick="SelectButton_Click"  
        runat="server"/> 

      <br/>

      <asp:label id="MessageLabel" 
        runat="server" />

    </form>
  </body>
</html>
   

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Bibliothèque de classes .NET Framework
SelectedDatesCollection, classe

Encapsule une collection d'objets System..::.DateTime représentant les dates sélectionnées dans un contrôle Calendar. Cette classe ne peut pas être héritée.

System..::.Object
  System.Web.UI.WebControls..::.SelectedDatesCollection

Espace de noms :  System.Web.UI.WebControls
Assembly :  System.Web (dans System.Web.dll)
Visual Basic
Public NotInheritable Class SelectedDatesCollection _
    Implements ICollection, IEnumerable
C#
public sealed class SelectedDatesCollection : ICollection, 
    IEnumerable
VisualC++
public ref class SelectedDatesCollection sealed : ICollection, 
    IEnumerable
F#
[<Sealed>]
type SelectedDatesCollection =  
    class
        interface ICollection
        interface IEnumerable
    end

Le type SelectedDatesCollection expose les membres suivants.

  NomDescription
Méthode publiqueSelectedDatesCollectionInitialise une nouvelle instance de la classe SelectedDatesCollection avec la liste de dates spécifiée.
Début
  NomDescription
Propriété publiqueCountObtient le nombre d'objets System..::.DateTime dans la collection SelectedDatesCollection.
Propriété publiqueIsReadOnlyObtient une valeur indiquant si la collection SelectedDatesCollection est en lecture seule.
Propriété publiqueIsSynchronizedObtient une valeur indiquant si l'accès à la collection SelectedDatesCollection est synchronisé (thread-safe).
Propriété publiqueItemObtient un objet System..::.DateTime situé à l'index spécifié dans la collection SelectedDatesCollection.
Propriété publiqueSyncRootObtient l'objet qui peut être utilisé pour synchroniser l'accès à la collection SelectedDatesCollection.
Début
  NomDescription
Méthode publiqueAddAjoute l'objet System..::.DateTime spécifié à la fin de la collection SelectedDatesCollection.
Méthode publiqueClearSupprime tous les objets System..::.DateTime de la collection.
Méthode publiqueContainsRetourne une valeur indiquant si la collection SelectedDatesCollection contient l'objet System..::.DateTime spécifié.
Méthode publiqueCopyToCopie les éléments de la collection SelectedDatesCollection dans le System..::.Array spécifié, à commencer par l'index indiqué.
Méthode publiqueEquals(Object)Détermine si l'Object spécifié est égal à l'Object en cours. (Hérité de Object.)
Méthode protégéeFinalizeAutorise un objet à tenter de libérer des ressources et d'exécuter d'autres opérations de netto***ge avant qu'il ne soit récupéré par l'opération garbage collection. (Hérité de Object.)
Méthode publiqueGetEnumeratorRetourne un objet implémenté par System.Collections..::.IEnumerator qui contient tous les objets System..::.DateTime de la collection SelectedDatesCollection.
Méthode publiqueGetHashCodeSert de fonction de hachage pour un type particulier. (Hérité de Object.)
Méthode publiqueGetTypeObtient le Type de l'instance actuelle. (Hérité de Object.)
Méthode protégéeMemberwiseCloneCrée une copie superficielle de l'objet Object actif. (Hérité de Object.)
Méthode publiqueRemoveSupprime de la collection SelectedDatesCollection l'objet System..::.DateTime spécifié.
Méthode publiqueSelectRangeAjoute la plage de dates spécifiée à la collection SelectedDatesCollection.
Méthode publiqueToStringRetourne une chaîne qui représente l'objet actuel. (Hérité de Object.)
Début
  NomDescription
Méthode d'extension publiqueAsParallelActive la parallélisation d'une requête. (Défini par ParallelEnumerable.)
Méthode d'extension publiqueAsQueryableConvertit un IEnumerable en IQueryable. (Défini par Queryable.)
Méthode d'extension publiqueCast<(Of <(TResult>)>)Convertit les éléments d'un IEnumerable vers le type spécifié. (Défini par Enumerable.)
Méthode d'extension publiqueOfType<(Of <(TResult>)>)Filtre les éléments d'un IEnumerable en fonction du type spécifié. (Défini par Enumerable.)
Début

Utilisez cette classe pour gérer par programme une collection d'objets System..::.DateTime représentant les dates sélectionnées dans un contrôle Calendar. Cette classe est généralement utilisée pour ajouter des dates dans la collection ou en supprimer.

Cette collection ne stocke que des dates complètes. La partie horaire de chaque System..::.DateTime est supprimée. Les dates sont stockées en ordre croissant. S'il y a des dates en double, une seule est stockée dans la collection.

L'exemple de code suivant illustre la sélection de dates par programme dans le contrôle Calendar à l'aide de la classe SelectedDatesCollection.

Visual Basic
<%@ Page Language="VB"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

    DisplayCalendar.VisibleDate = DisplayCalendar.TodaysDate

  End Sub

  Sub SelectButton_Click(ByVal sender As Object, ByVal e As EventArgs)

    Dim current_day As Integer = DisplayCalendar.VisibleDate.Day
    Dim current_month As Integer = DisplayCalendar.VisibleDate.Month
    Dim current_year As Integer = DisplayCalendar.VisibleDate.Year

    DisplayCalendar.SelectedDates.Clear()

    ' Iterate through the current month and add all Wednesdays to the 
    ' SelectedDates collection of the Calendar control.
    Dim i As Integer
    For i = 1 To System.DateTime.DaysInMonth(current_year, current_month)

      Dim currentDate As New DateTime(current_year, current_month, i)
      If currentDate.DayOfWeek = DayOfWeek.Wednesday Then

        DisplayCalendar.SelectedDates.Add(currentDate)

      End If

    Next

    MessageLabel.Text = "Selection Count = " + DisplayCalendar.SelectedDates.Count.ToString()

  End Sub

  Sub DisplayCalendar_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)

    MessageLabel.Text = "Selection Count = " & DisplayCalendar.SelectedDates.Count.ToString()

  End Sub

</script> 

<html  >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <asp:calendar id="DisplayCalendar" runat="server"  
        selectionmode="DayWeekMonth" 
        onselectionchanged="DisplayCalendar_SelectionChanged" />

      <hr />

      <asp:button id="SelectButton"
        text="Select All Weds in Month" 
        onclick="SelectButton_Click"  
        runat="server"/> 

      <br/>

      <asp:label id="MessageLabel" 
        runat="server" />

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void Page_Load(Object sender, EventArgs e) 
  {
    DisplayCalendar.VisibleDate = DisplayCalendar.TodaysDate;
  }

  void SelectButton_Click(Object sender, EventArgs e) 
  {

    int current_day = DisplayCalendar.VisibleDate.Day;
    int current_month = DisplayCalendar.VisibleDate.Month;
    int current_year = DisplayCalendar.VisibleDate.Year;

    DisplayCalendar.SelectedDates.Clear();

    // Iterate through the current month and add all Wednesdays to the 
    // SelectedDates collection of the Calendar control.
    for (int i = 1; i <= System.DateTime.DaysInMonth(current_year, current_month); i++)
    {
       DateTime currentDate = new DateTime(current_year, current_month, i);
       if (currentDate.DayOfWeek == DayOfWeek.Wednesday)
       {
         DisplayCalendar.SelectedDates.Add(currentDate);
       }
    }

     MessageLabel.Text = "Selection Count = " + DisplayCalendar.SelectedDates.Count.ToString();

  }

  void DisplayCalendar_SelectionChanged(Object sender, EventArgs e) 
  {
    MessageLabel.Text = "Selection Count = " + DisplayCalendar.SelectedDates.Count.ToString();
  }

</script> 

<html  >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <asp:calendar id="DisplayCalendar" runat="server"  
        selectionmode="DayWeekMonth" 
        onselectionchanged="DisplayCalendar_SelectionChanged" />

      <hr />

      <asp:button id="SelectButton"
        text="Select All Weds in Month" 
        onclick="SelectButton_Click"  
        runat="server"/> 

      <br/>

      <asp:label id="MessageLabel" 
        runat="server" />

    </form>
  </body>
</html>
   

.NET Framework

Pris en charge dans : 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows XP SP2 Édition x64, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2

Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.
Tous les membres static (Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.
Contenu de la communauté   Qu'est-ce que le Contenu de la communauté ?
Ajouter du contenu RSS  Annotations
Processing
© 2012 Microsoft. Tous droits réservés. Conditions d'utilisation | Marques | Confidentialité
Page view tracker