RectangleShape, classe
Mise à jour : novembre 2007
Représente un contrôle affiché sous la forme d'un carré, d'un rectangle ou d'un carré ou rectangle à angles arrondis.
Espace de noms : Microsoft.VisualBasic.PowerPacks
Assembly : Microsoft.VisualBasic.PowerPacks.Vs (dans Microsoft.VisualBasic.PowerPacks.Vs.dll)
Syntaxe
<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
Notes
Le contrôle RectangleShape vous permet de dessiner des rectangles sur un formulaire ou conteneur au moment du design ou de l'exécution.
Lorsque vous ajoutez un contrôle Line ou Shape à un formulaire ou un conteneur, un objet ShapeContainer invisible est créé. Le ShapeContainer sert de surface de dessin pour les formes au sein de chaque contrôle conteneur. Chaque ShapeContainer possède un ShapeCollection correspondant qui vous permet de parcourir les contrôles Line et Shape contenus dans le ShapeContainer.
Lorsque vous créez un contrôle RectangleShape au moment de l'exécution, vous devez également créer un ShapeContainer et définir la propriété Parent de RectangleShape sur ShapeContainer.
Exemples
L'exemple suivant crée un ShapeContainer et un RectangleShape, les ajoute à un formulaire et affiche un rectangle.
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;
}
Hiérarchie d'héritage
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
Microsoft.VisualBasic.PowerPacks.Shape
Microsoft.VisualBasic.PowerPacks.SimpleShape
Microsoft.VisualBasic.PowerPacks.RectangleShape
Sécurité des threads
Tous les membres static (Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.
Voir aussi
Référence
Microsoft.VisualBasic.PowerPacks, espace de noms
Autres ressources
Introduction aux contrôles Line et Shape (Visual Studio)
Comment : dessiner des lignes avec le contrôle LineShape (Visual Studio)
Comment : dessiner des formes avec les contrôles OvalShape et RectangleShape (Visual Studio)