Condividi tramite


Proprietà ShapeContainer.Shapes

Ottiene la raccolta di forme contenute in ShapeContainer.

Spazio dei nomi:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Sintassi

'Dichiarazione
<BrowsableAttribute(False)> _
Public ReadOnly Property Shapes As ShapeCollection
[BrowsableAttribute(false)]
public ShapeCollection Shapes { get; }
[BrowsableAttribute(false)]
public:
property ShapeCollection^ Shapes {
    ShapeCollection^ get ();
}
[<BrowsableAttribute(false)>]
member Shapes : ShapeCollection
function get Shapes () : ShapeCollection

Valore proprietà

Tipo: Microsoft.VisualBasic.PowerPacks.ShapeCollection
In ShapeCollection rappresentazione della libreria di forme contenute in ShapeContainer.

Note

In ShapeCollection funge da padre a una raccolta di forme.Ad esempio, quando diverse forme sono stati aggiunti a Form, ogni forma è un membro di ShapeCollection assegnato a ShapeContainer il form.

È possibile utilizzare le forme in ShapeCollection assegnato a ShapeContainer utilizzando i metodi disponibili in ShapeCollection classe.

Quando si aggiungono diverse forme a un oggetto ShapeContainer, è consigliabile chiamare SuspendLayout metodo prima di inizializzare le forme da aggiungere.Dopo avere aggiunto le forme a ShapeContainer, chiamare ResumeLayout metodo.Tramite SuspendLayout e ResumeLayout aumento delle prestazioni delle applicazioni che presentano molte forme.

Esempi

L'esempio seguente consente di rimuovere un oggetto Shape da ShapeCollection di un form (rappresentato da Shapes proprietà) se è un membro della raccolta.Questo esempio presuppone che l'utente abbia a LineShape, OvalShapee RectangleShape controllare in un form.Quando una forma è selezionata, verrà rimossa da ShapeCollection a meno che non sia l'ultimo il form nella raccolta.

Private Sub Shapes_Click(
    ByVal sender As System.Object, 
    ByVal e As System.EventArgs
  ) Handles RectangleShape1.Click, 
            OvalShape1.Click, LineShape1.Click

    ' Determine whether the shape is in the collection.
    If ShapeContainer1.Shapes.Contains(sender) Then
        ' If the index is greater than 0, remove the shape.
        If ShapeContainer1.Shapes.IndexOf(sender) > 0 Then
            ShapeContainer1.Shapes.Remove(sender)
        End If
    End If
End Sub
private void Shapes_Click(System.Object sender, System.EventArgs e)
{
    // Determine whether the shape is in the collection.
    if (shapeContainer1.Shapes.Contains((Shape) sender))
    // If the index is greater than 0, remove the shape.
    {
        if (shapeContainer1.Shapes.IndexOf((Shape)sender) > 0)
        {
            shapeContainer1.Shapes.Remove((Shape)sender);
        }
    }
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

ShapeContainer Classe

Spazio dei nomi Microsoft.VisualBasic.PowerPacks

Altre risorse

Introduzione ai controlli Line e Shape (Visual Studio)

Procedura: disegnare linee con il controllo LineShape (Visual Studio)

Procedura: disegnare forme con i controlli OvalShape e RectangleShape (Visual Studio)