Classe RectangleShape
Aggiornamento: novembre 2007
Rappresenta un controllo visualizzato come quadrato, rettangolo, quadrato arrotondato o rettangolo arrotondato.
Spazio dei nomi: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Sintassi
<ToolboxBitmapAttribute(GetType(RectangleShape), "Microsoft.VisualBasic.PowerPacks.RectangleShape.bmp")> _
Public Class RectangleShape _
Inherits SimpleShape
Dim instance As RectangleShape
[ToolboxBitmapAttribute(typeof(RectangleShape), "Microsoft.VisualBasic.PowerPacks.RectangleShape.bmp")]
public class RectangleShape : SimpleShape
[ToolboxBitmapAttribute(typeof(RectangleShape), L"Microsoft.VisualBasic.PowerPacks.RectangleShape.bmp")]
public ref class RectangleShape : public SimpleShape
public class RectangleShape extends SimpleShape
Note
Il controllo RectangleShape consente di disegnare rettangoli in un form o in un contenitore in fase di progettazione o di esecuzione.
Quando si aggiunge un controllo Line o Shape a un form o a un contenitore, viene creato un oggetto ShapeContainer invisibile. L'oggetto ShapeContainer funge da superficie di disegno per le forme all'interno di ogni controllo contenitore. Ogni oggetto ShapeContainer dispone di un oggetto ShapeCollection corrispondente, che consente di scorrere i controlli Line e Shape contenuti in ShapeContainer.
Quando si crea un controllo RectangleShape in fase di esecuzione, è necessario creare anche un oggetto ShapeContainer e impostare la proprietà Parent di RectangleShape su ShapeContainer.
Esempi
Nell'esempio riportato di seguito vengono creati un oggetto ShapeContainer e un oggetto RectangleShape, tali oggetti vengono aggiunti a un form e viene visualizzato un rettangolo.
Private Sub DrawRectangle()
Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
Dim rect1 As New Microsoft.VisualBasic.PowerPacks.RectangleShape
' Set the form as the parent of the ShapeContainer.
canvas.Parent = Me
' Set the ShapeContainer as the parent of the RectangleShape.
rect1.Parent = canvas
' Set the location and size of the rectangle.
rect1.Left = 10
rect1.Top = 10
rect1.Width = 300
rect1.Height = 100
End Sub
private void DrawRectangle()
{
Microsoft.VisualBasic.PowerPacks.ShapeContainer canvas =
new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
Microsoft.VisualBasic.PowerPacks.RectangleShape rect1 =
new Microsoft.VisualBasic.PowerPacks.RectangleShape();
// Set the form as the parent of the ShapeContainer.
canvas.Parent = this;
// Set the ShapeContainer as the parent of the RectangleShape.
rect1.Parent = canvas;
// Set the location and size of the rectangle.
rect1.Left = 10;
rect1.Top = 10;
rect1.Width = 300;
rect1.Height = 100;
}
Gerarchia di ereditarietà
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
Microsoft.VisualBasic.PowerPacks.Shape
Microsoft.VisualBasic.PowerPacks.SimpleShape
Microsoft.VisualBasic.PowerPacks.RectangleShape
Codice thread safe
Qualsiasi membro static (Shared in Visual Basic) pubblico di questo tipo è thread-safe. I membri di istanza non sono garantiti come thread-safe.
Vedere anche
Riferimenti
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)