共用方式為


HotSpotCollection.Remove(HotSpot) 方法

定義

HotSpot 集合中移除指定的 HotSpotCollection 物件。

public:
 void Remove(System::Web::UI::WebControls::HotSpot ^ spot);
public void Remove (System.Web.UI.WebControls.HotSpot spot);
member this.Remove : System.Web.UI.WebControls.HotSpot -> unit
Public Sub Remove (spot As HotSpot)

參數

spot
HotSpot

要從集合移除的 HotSpot 物件。

範例

下列程式代碼範例示範如何以程序設計方式將兩 CircleHotSpotImageMap 物件新增至 控件。 將兩 CircleHotSpotHotSpotCollection 物件新增至集合之後, Remove 會使用 方法從集合中刪除 Circle1 。 若要讓這個範例正確運作,您必須提供 ImageUrl 屬性自己的映像,並適當地更新映像的路徑,讓應用程式可以找到它。

<%@ 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 Remove method to delete the Circle1 
    // object from the HotSpotCollection.
    Shop.HotSpots.Remove (Circle1);
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
  <title>HotSpotCollection.Remove Example</title>
</head>
  <body>
    <form id="Form1" runat="server">
    
      <h3>HotSpotCollection.Remove 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 Remove method to delete the Circle1 
    ' object from the HotSpotCollection.
    Shop.HotSpots.Remove(Circle1)
    
  End Sub

</script>

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

備註

方法 Remove 會從集合中移除指定的 HotSpot 物件。 HotSpot若要從集合中移除位於指定索引位置的 物件,請使用 RemoveAt 方法。

若要將新 HotSpot 物件新增至集合,請使用 AddInsert 方法。

適用於

另請參閱