.NET Framework Class Library PanelStyle Class Represents the style for a Panel control.

Inheritance Hierarchy
Namespace:
System.Web.UI.WebControls
Assembly:
System.Web (in System.Web.dll)

Syntax
Public Class PanelStyle _
Inherits Style
public class PanelStyle : Style
public ref class PanelStyle : public Style
type PanelStyle =
class
inherit Style
end
The PanelStyle type exposes the following members.

Constructors
|
| Name | Description |
|---|
.gif) | PanelStyle | Initializes a new instance of the PanelStyle class. | Top

Methods

Events

Explicit Interface Implementations

Remarks
The PanelStyle class is used to represent the style settings for a panel control. It encapsulates the properties that control the appearance of a panel and can be applied to multiple panel controls to provide a common appearance. You can specify an image to display in the background of the panel by setting the BackImageUrl property. The horizontal alignment of the contents of the panel is indicated by the HorizontalAlign property. The direction of controls that contain text within the panel control can be specified by setting the Direction property.

Examples
The following code example demonstrates creating a PanelStyle object and setting its properties. This example has two parts: A partial class, PanelStylecs_aspx, that demonstrates creating a new PanelStyle object and setting its properties. A Web Forms page that uses the PanelStylecs_aspx example as its code-behind file. The first part of the example demonstrates creating a PanelStyle object, myPanelStyle, and setting its properties. Then the ApplyStyle method is called for both the Panel1 panel and the Panel2 panel, and myPanelStyle is applied to both of them.
Partial Class PanelStylevb_aspx
Inherits Page
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim panelState As StateBag = New StateBag()
Dim myPanelStyle As PanelStyle = New PanelStyle(panelState)
' Set the properties of the PanelStyle class.
myPanelStyle.HorizontalAlign = HorizontalAlign.Center
myPanelStyle.ScrollBars = ScrollBars.Both
myPanelStyle.Wrap = False
myPanelStyle.Direction = ContentDirection.LeftToRight
myPanelStyle.BackImageUrl = "~\images\picture.jpg"
' Use the ApplyStyle method of the Panel control to apply
' the settings from the myPanelStyle object.
Panel1.ApplyStyle(myPanelStyle)
Panel2.ApplyStyle(myPanelStyle)
End Sub
End Class
public partial class PanelStylecs_aspx : Page
{
void Page_Load(object sender, EventArgs e)
{
StateBag panelState = new StateBag();
PanelStyle myPanelStyle = new PanelStyle(panelState);
// Set the properties of the PanelStyle class.
myPanelStyle.HorizontalAlign = HorizontalAlign.Center;
myPanelStyle.ScrollBars = ScrollBars.Both;
myPanelStyle.Wrap = false;
myPanelStyle.Direction = ContentDirection.LeftToRight;
myPanelStyle.BackImageUrl = @"~\images\picture.jpg";
// Use the ApplyStyle method of the Panel control to apply
// the settings from the myPanelStyle object.
Panel1.ApplyStyle(myPanelStyle);
Panel2.ApplyStyle(myPanelStyle);
}
}
The second part of the example shows an .aspx file that is used with the previous example.
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="PanelStyle.vb" Inherits="PanelStylevb_aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head runat="server">
<title>PanelStyle Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>PanelStyle Example</h3>
<asp:Panel id="Panel1"
runat="server"
width="150"
height="50">
This is the Panel1 panel control.
</asp:Panel>
<br /><br />
<asp:Panel id="Panel2"
runat="server"
width="150"
height="50">
This is the Panel2 panel control.
</asp:Panel>
</form>
</body>
</html>
<%@ Page Language="C#" CodeFile="PanelStyle.cs" Inherits="PanelStylecs_aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head runat="server">
<title>PanelStyle Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>PanelStyle Example</h3>
<asp:Panel id="Panel1"
runat="server"
width="150"
height="50">
This is the Panel1 panel control.
</asp:Panel>
<br /><br />
<asp:Panel id="Panel2"
runat="server"
width="150"
height="50">
This is the Panel2 panel control.
</asp:Panel>
</form>
</body>
</html>

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also
|
Bibliothèque de classes .NET Framework PanelStyle, classe Représente le style d'un contrôle Panel.

Hiérarchie d'héritage
Espace de noms :
System.Web.UI.WebControls
Assembly :
System.Web (dans System.Web.dll)

Syntaxe
Public Class PanelStyle _
Inherits Style
public class PanelStyle : Style
public ref class PanelStyle : public Style
type PanelStyle =
class
inherit Style
end
Le type PanelStyle expose les membres suivants.

Constructeurs
|
| Nom | Description |
|---|
.gif) | PanelStyle | Initialise une nouvelle instance de la classe PanelStyle. | Début

Méthodes

Événements

Implémentations d'interface explicite

Notes
La classe PanelStyle sert à représenter les paramètres de style d'un contrôle de panneau. Elle encapsule les propriétés qui contrôlent l'apparence d'un panneau et qui peuvent être appliquées à plusieurs contrôles de panneau afin d'uniformiser leur apparence. Vous pouvez spécifier une image à afficher à l'arrière-plan du panneau en donnant une valeur à la propriété BackImageUrl. L'alignement horizontal du contenu du panneau est indiqué par la propriété HorizontalAlign. La direction des contrôles qui contiennent le texte au sein du contrôle de panneau peut être spécifiée en donnant une valeur à la propriété Direction.

Exemples
L'exemple de code suivant montre comment créer un objet PanelStyle et paramétrer ses propriétés. Cet exemple se compose de deux parties : Une classe partielle, PanelStylecs_aspx, qui montre comment créer un nouvel objet PanelStyle et paramétrer ses propriétés. Une page Web Forms qui utilise l'exemple PanelStylecs_aspx comme fichier de code-behind. La première partie de l'exemple montre comment créer un objet PanelStyle, myPanelStyle, et paramétrer ses propriétés. La méthode ApplyStyle est ensuite appelée, à la fois pour le panneau Panel1 et le panneau Panel2, et myPanelStyle est appliquée au deux.
Partial Class PanelStylevb_aspx
Inherits Page
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim panelState As StateBag = New StateBag()
Dim myPanelStyle As PanelStyle = New PanelStyle(panelState)
' Set the properties of the PanelStyle class.
myPanelStyle.HorizontalAlign = HorizontalAlign.Center
myPanelStyle.ScrollBars = ScrollBars.Both
myPanelStyle.Wrap = False
myPanelStyle.Direction = ContentDirection.LeftToRight
myPanelStyle.BackImageUrl = "~\images\picture.jpg"
' Use the ApplyStyle method of the Panel control to apply
' the settings from the myPanelStyle object.
Panel1.ApplyStyle(myPanelStyle)
Panel2.ApplyStyle(myPanelStyle)
End Sub
End Class
public partial class PanelStylecs_aspx : Page
{
void Page_Load(object sender, EventArgs e)
{
StateBag panelState = new StateBag();
PanelStyle myPanelStyle = new PanelStyle(panelState);
// Set the properties of the PanelStyle class.
myPanelStyle.HorizontalAlign = HorizontalAlign.Center;
myPanelStyle.ScrollBars = ScrollBars.Both;
myPanelStyle.Wrap = false;
myPanelStyle.Direction = ContentDirection.LeftToRight;
myPanelStyle.BackImageUrl = @"~\images\picture.jpg";
// Use the ApplyStyle method of the Panel control to apply
// the settings from the myPanelStyle object.
Panel1.ApplyStyle(myPanelStyle);
Panel2.ApplyStyle(myPanelStyle);
}
}
La deuxième partie de l'exemple montre un fichier .aspx utilisé avec l'exemple précédent.
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="PanelStyle.vb" Inherits="PanelStylevb_aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head runat="server">
<title>PanelStyle Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>PanelStyle Example</h3>
<asp:Panel id="Panel1"
runat="server"
width="150"
height="50">
This is the Panel1 panel control.
</asp:Panel>
<br /><br />
<asp:Panel id="Panel2"
runat="server"
width="150"
height="50">
This is the Panel2 panel control.
</asp:Panel>
</form>
</body>
</html>
<%@ Page Language="C#" CodeFile="PanelStyle.cs" Inherits="PanelStylecs_aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head runat="server">
<title>PanelStyle Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>PanelStyle Example</h3>
<asp:Panel id="Panel1"
runat="server"
width="150"
height="50">
This is the Panel1 panel control.
</asp:Panel>
<br /><br />
<asp:Panel id="Panel2"
runat="server"
width="150"
height="50">
This is the Panel2 panel control.
</asp:Panel>
</form>
</body>
</html>

Informations de version
.NET FrameworkPris en charge dans : 4, 3.5, 3.0, 2.0

Plateformes
Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows XP SP2 Édition x64, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

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
|