指定した System.Array に SelectedDatesCollection コレクションの項目をコピーします。コピー操作は、指定したインデックス位置から始まります。
名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文
'宣言
Public Sub CopyTo ( _
array As Array, _
index As Integer _
)
'使用
Dim instance As SelectedDatesCollection
Dim array As Array
Dim index As Integer
instance.CopyTo(array, index)
public void CopyTo (
Array array,
int index
)
public:
virtual void CopyTo (
Array^ array,
int index
) sealed
public final void CopyTo (
Array array,
int index
)
public final function CopyTo (
array : Array,
index : int
)
適用できません。
パラメータ
- array
SelectedDatesCollection の項目のコピー先となる、インデックス番号が 0 から始まる System.Array。
- index
項目のコピー先として指定されている System.Array の最初のインデックス。
解説
このメソッドを使用して、指定した System.Array に SelectedDatesCollection コレクションの内容をコピーします。コピー操作は、指定したインデックス位置から始まります。
メモ : |
|---|
array パラメータには、インデックス番号が 0 から始まる System.Array を指定する必要があります。 |
使用例
CopyTo メソッドを使用して、指定した配列に SelectedDatesCollection の項目をコピーする方法を次のコード例に示します。
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ASP.NET Example</title>
<script runat="server">
Sub Select_Change(sender As Object, e As EventArgs)
Dim myDateArray(Calendar1.SelectedDates.Count) As DateTime
' Copy the collection to array.
Calendar1.SelectedDates.CopyTo(myDateArray, 0)
Label1.Text = "The dates selected are: "
' Loop through the IEnumerator and display the contents.
Dim theDate As DateTime
For Each theDate In myDateArray
Label1.Text &= " " & theDate.Day.ToString()
Next
End Sub
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Calendar ID="Calendar1" runat="server"
SelectionMode="DayWeekMonth"
OnSelectionChanged="Select_Change"/>
<hr />
Select dates from the Calendar.<br /><br />
<asp:Label id="Label1" runat="server" />
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ASP.NET Example</title>
<script runat="server">
void Select_Change(Object sender, EventArgs e)
{
DateTime[] myDateArray = new DateTime[Calendar1.SelectedDates.Count];
// Copy the collection to an array.
Calendar1.SelectedDates.CopyTo(myDateArray, 0);
Label1.Text = "The dates selected are: ";
// Loop through the IEnumerator and display the contents.
foreach (DateTime date in myDateArray)
{
Label1.Text += " " + date.Day.ToString();
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Calendar ID="Calendar1" runat="server"
SelectionMode="DayWeekMonth"
OnSelectionChanged="Select_Change"/>
<hr />
Select dates from the Calendar.<br /><br />
<asp:Label id="Label1" runat="server" />
</form>
</body>
</html>
プラットフォーム
Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition
Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。
バージョン情報
.NET Framework
サポート対象 : 3.0,2.0,1.1,1.0
参照
関連項目
SelectedDatesCollection クラス
SelectedDatesCollection メンバ
System.Web.UI.WebControls 名前空間
System.Array
メモ :