HotSpotCollection.RemoveAt(Int32) 方法

定义

从集合中移除位于指定索引位置的 HotSpot 对象。Removes the HotSpot object at the specified index location from the collection.

public:
 void RemoveAt(int index);
public void RemoveAt (int index);
member this.RemoveAt : int -> unit
Public Sub RemoveAt (index As Integer)

参数

index
Int32

移除 HotSpot 对象的位置的数组索引。The array index from which to remove the HotSpot object.

示例

下面的代码示例演示如何以编程方式将两个 CircleHotSpot 对象添加到 ImageMap 控件中。The following code example demonstrates how to programmatically add two CircleHotSpot objects to an ImageMap control. 将两个 CircleHotSpot 对象添加到集合后 HotSpotCollection ,该 RemoveAt 方法用于删除位于集合中第一个索引处的对象。After the two CircleHotSpot objects are added to the HotSpotCollection collection, the RemoveAt method is used to delete the object located at the first index in the collection. 若要使此示例正常工作,必须为属性提供自己的图像 ImageUrl ,并适当地更新图像的路径,以便应用程序可以找到它。For this example to work correctly, you must supply your own image for the ImageUrl property and update the path to the image appropriately so that the application can locate it.

<%@ 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)
  {
    // Programmatically create a CircleHotSpot object.
    CircleHotSpot Circle1 = new CircleHotSpot();
    Circle1.HotSpotMode = HotSpotMode.Navigate;
    Circle1.NavigateUrl = "http://www.tailspintoys.com";
    Circle1.X = 145;
    Circle1.Y = 120;
    Circle1.Radius = 75;
    Circle1.AlternateText = "Shop for toys";

    // Programmatically create a second CircleHotSpot object.
    CircleHotSpot Circle2 = new CircleHotSpot();
    Circle2.HotSpotMode = HotSpotMode.Navigate;
    Circle2.NavigateUrl = "http://www.cohowinery.com";
    Circle2.X = 145;
    Circle2.Y = 290;
    Circle2.Radius = 75;
    Circle2.AlternateText = "Shop for wine";

    // Add the HotSpot objects to the ImageMap's 
    // HotSpotCollection.            
    Shop.HotSpots.Add(Circle1);
    Shop.HotSpots.Add(Circle2);

    // Use the RemoveAt method to delete the HotSpot 
    // object at the first index in HotSpotCollection.
    Shop.HotSpots.RemoveAt(0);
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
  <title>HotSpotCollection.RemoveAt Example</title>
</head>
  <body>
    <form id="Form1" runat="server">
    
      <h3>HotSpotCollection.RemoveAt Example</h3>
      
      <h4>Shopping Choices:</h4>
      
      <asp:imagemap id="Shop"           
        imageurl="Images/ShopChoice.jpg"
        alternatetext="Shopping choices" 
        runat="Server">
      </asp:imagemap>
      
    </form>      
  </body>
</html>
<%@ 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)
    
    ' Programmatically create a CircleHotSpot object.
    Dim Circle1 As New CircleHotSpot
    Circle1.HotSpotMode = HotSpotMode.Navigate
    Circle1.NavigateUrl = "http://www.tailspintoys.com"
    Circle1.X = 145
    Circle1.Y = 120
    Circle1.Radius = 75
    Circle1.AlternateText = "Shop for toys"
           
    ' Programmatically create a second CircleHotSpot object.
    Dim Circle2 As New CircleHotSpot
    Circle2.HotSpotMode = HotSpotMode.Navigate
    Circle2.NavigateUrl = "http://www.cohowinery.com"
    Circle2.X = 145
    Circle2.Y = 290
    Circle2.Radius = 75
    Circle2.AlternateText = "Shop for wine"
    
    ' Add the HotSpot objects to the ImageMap's 
    ' HotSpotCollection.            
    Shop.HotSpots.Add(Circle1)
    Shop.HotSpots.Add(Circle2)
    
    ' Use the RemoveAt method to delete the HotSpot 
    ' object at the first index in HotSpotCollection.
    Shop.HotSpots.RemoveAt(0)
    
  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
  <title>HotSpotCollection.RemoveAt Example</title>
</head>
  <body>
    <form id="Form1" runat="server">
    
      <h3>HotSpotCollection.RemoveAt Example</h3>
      
      <h4>Shopping Choices:</h4>
      
      <asp:imagemap id="Shop"           
        imageurl="Images/ShopChoice.jpg"
        alternatetext="Shopping choices" 
        runat="Server">
      </asp:imagemap>
      
    </form>      
  </body>
</html>

注解

RemoveAt方法 HotSpot 从集合中移除位于指定索引位置的对象。The RemoveAt method removes the HotSpot object at the specified index location from the collection. 若要 HotSpot 按名称从集合中删除特定对象,请使用 Remove 方法。To remove a specific HotSpot object from the collection by name, use the Remove method.

若要将新 HotSpot 对象添加到集合,请使用 AddInsert 方法。To add new HotSpot objects to the collection, use the Add or the Insert method.

适用于

另请参阅