HotSpotCollection.Item[Int32] プロパティ

定義

HotSpot コレクション内の指定したインデックス位置の HotSpotCollection オブジェクトへの参照を取得します。

public:
 property System::Web::UI::WebControls::HotSpot ^ default[int] { System::Web::UI::WebControls::HotSpot ^ get(int index); };
public System.Web.UI.WebControls.HotSpot this[int index] { get; }
member this.Item(int) : System.Web.UI.WebControls.HotSpot
Default Public ReadOnly Property Item(index As Integer) As HotSpot

パラメーター

index
Int32

コレクション内の HotSpot オブジェクトの位置を指定する序数インデックス値。

プロパティ値

HotSpot コレクション内の指定したインデックス位置の HotSpotCollection オブジェクト。

次のコード例では、 プロパティをItem[]使用して、コントロールのコレクションにImageMap含まれるオブジェクトに直接アクセスHotSpotし、各オブジェクトのHotSpotCollectionプロパティの値をページ上のAlternateTextラベルに表示する方法を示します。 この例を正しく機能させるには、 プロパティに独自のイメージを ImageUrl 指定し、イメージへのパスを適切に更新して、アプリケーションがイメージを見つけられるようにする必要があります。

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

  void Page_Load(object sender, EventArgs e)
  {
    // Use the indexer to access each object in the 
    // HotSpotCollection and display the value of
    // its AlternateText property to the user. 
    for (int i = 0; i <= Shop.HotSpots.Count - 1; i++)
    {
      Label1.Text += "<br />" + Shop.HotSpots[i].AlternateText + "<br />";
    }  
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
  <title>HotSpotCollection.Item Property Example</title>
</head>
  <body>
    <form id="Form1" runat="server">
    
      <h3>HotSpotCollection.Item Property Example</h3>
      
      <h4>Shopping Choices:</h4>
      
      <asp:imagemap id="Shop"           
        imageurl="Images/ShopChoice.jpg" 
        alternatetext="Shopping choices"
        runat="Server">    
        
        <asp:circlehotspot
          navigateurl="http://www.tailspintoys.com"
          x="145"
          y="120"
          radius="75"
          hotspotmode="Navigate"
          alternatetext="Shop for toys">           
        </asp:circlehotspot> 
        
        <asp:circlehotspot
          navigateurl="http://www.cohowinery.com"
          x="145"
          y="290"
          radius="75"
          hotspotmode="Navigate"
          alternatetext="Shop for wine">
        </asp:circlehotspot>     
          
      </asp:imagemap> 
      
      <asp:label id="Label1"
        runat="Server">
      </asp:label>      
                 
    </form>      
  </body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server" language="vb">
  
  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    
    ' Use the Item property to access each object in the 
    ' HotSpotCollection and display the value of
    ' its AlternateText property to the user. 
    For i As Integer = 0 To Shop.HotSpots.Count - 1
      Label1.Text += "<br />" + Shop.HotSpots.Item(i).AlternateText + "<br />"
    Next
  
  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
  <title>HotSpotCollection.Item Property Example</title>
</head>
  <body>
    <form id="Form1" runat="server">
    
      <h3>HotSpotCollection.Item Property Example</h3>
      
      <h4>Shopping Choices:</h4>
      
      <asp:imagemap id="Shop"           
        imageurl="Images/ShopChoice.jpg" 
        alternatetext="Shopping choices"
        runat="Server">    
        
        <asp:circlehotspot
          navigateurl="http://www.tailspintoys.com"
          x="145"
          y="120"
          radius="75"
          hotspotmode="Navigate"
          alternatetext="Shop for toys">           
        </asp:circlehotspot> 
        
        <asp:circlehotspot
          navigateurl="http://www.cohowinery.com"
          x="145"
          y="290"
          radius="75"
          hotspotmode="Navigate"
          alternatetext="Shop for wine">
        </asp:circlehotspot>     
          
      </asp:imagemap> 
      
      <asp:label id="Label1"
        runat="Server">
      </asp:label>      
                 
    </form>      
  </body>
</html>

注釈

配列表記を使用して、このインデクサーを使用して、指定したインデックス位置にあるコレクション内のオブジェクトにアクセス HotSpot します。 インデクサーを使用すると、コレクション内のオブジェクトを HotSpot 直接変更または置換できます。

適用対象

こちらもご覧ください