Panel クラス
アセンブリ: System.Web.Mobile (system.web.mobile.dll 内)
構文
解説
パネルは、入れ子にできるコンテナ コントロールです。パネルに設定されている属性は、そのパネルに格納されているコントロールによって継承されます。
-
スタイル属性をパネル上で設定しておくことにより、一連のコントロールにスタイル属性を一元的に適用します。パネルにはスタイルの継承が適用されるため、パネルで設定した属性は、そのパネルに含まれるコントロールによって継承できます。
-
改ページ位置を自動修正するときに一緒に保持するコントロールに関する情報を ASP.NET ページ フレームワークに提供します。既定では、パネルのコンテンツは同じページに保持されます。この動作は、パネルの Paginate プロパティを設定することによって変更できます。
Panel のテキストの内容には、リテラル テキストとそれに付随するマークアップ タグを一緒に含めることができます。詳細については、「フォーム マークアップ内のリテラル テキスト」を参照してください。
ページの読み込み中にパネルのプロパティを設定する方法、およびパネルのプロパティを操作してコマンド クリックに応答するようにする関数を定義する方法を次のコード例に示します。このコードはまた、ページの読み込み時に、デバイス固有のコンテンツ テンプレート内のラベルを検索し、第 2 のパネル内でこれを変更します。
<%@ Page Language="C#" Inherits="System.Web.UI.MobileControls.MobilePage" %> <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %> <%@ Import Namespace="System.Drawing" %> <script runat="server"> public void Page_Load(Object sender, EventArgs e) { // Set Panel1 properties Panel1.Wrapping = Wrapping.NoWrap; Panel1.Alignment = Alignment.Center; Panel1.StyleReference = "title"; // Find Label in Panel2 Control ctl = Panel2.Content.FindControl("lblStatusToday"); if (ctl != null) ((System.Web.UI.MobileControls.Label)ctl).Text = "I found this label"; } public void MakeFontRed(Object sender, EventArgs e) { Panel1.ForeColor = Color.Red; } public void MakeFontBlue(Object sender, EventArgs e) { Panel1.ForeColor = Color.Blue; } </script> <html > <body> <mobile:Form runat="server" id="Form1"> <!-- First Panel --> <mobile:Panel runat="server" id="Panel1"> <mobile:TextView runat="server" id="TextView1"> A Panel provides a grouping mechanism<br /> for organizing controls. </mobile:TextView> </mobile:Panel> <mobile:Command runat="server" id="Command1" BreakAfter="false" Text="Make Font Red" OnClick="MakeFontRed"/> <mobile:Command runat="server" id="Command2" BreakAfter="true" Text="Make Font Blue" OnClick="MakeFontBlue"/> <!-- Second Panel --> <mobile:Panel ID="Panel2" Runat="server"> <mobile:DeviceSpecific id="DeviceSpecific1" runat="server"> <!-- Filter and template for HTML32 devices --> <Choice Filter="isHTML32" Xmlns="http://schemas.microsoft.com/mobile/html32template"> <ContentTemplate> <mobile:Label id="Label1" runat="server"> HTML32 Template</mobile:Label> <mobile:Label ID="lblStatusToday" Runat="server"/> </ContentTemplate> </Choice> <!-- Default filter and template --> <Choice> <ContentTemplate> <mobile:Label ID="Label1" Runat="server"> Default Template</mobile:Label> <mobile:Label ID="lblStatusToday" Runat="server" /> </ContentTemplate> </Choice> </mobile:DeviceSpecific> </mobile:Panel> </mobile:Form> </body> </html>
System.Web.UI.Control
System.Web.UI.MobileControls.MobileControl
System.Web.UI.MobileControls.Panel
System.Web.UI.MobileControls.Form
System.Web.UI.MobileControls.TemplateContainer
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Panel クラス
アセンブリ: System.Web (system.web.dll 内)
構文
解説
Panel コントロールは、ほかのコントロールのコンテナです。プログラムによってコントロールを生成したり、コントロールのグループの非表示/表示を切り替えたり、コントロールのグループをローカライズしたりする場合に特に役立ちます。
Direction プロパティは、アラビア語やヘブライ語などの右から左に記述する言語のテキストを表示するために Panel コントロールの内容をローカライズする場合に役立ちます。
Panel コントロールには、その内容の動作や表示をカスタマイズできるプロパティがいくつか用意されています。BackImageUrl プロパティを使用して、Panel コントロールのカスタム イメージを表示します。ScrollBars プロパティを使用して、コントロールのスクロール バーを指定します。
Panel コントロールを使用して、プログラムによってコントロールを生成し、コントロールのグループの非表示/表示を切り替える方法を次の例に示します。
メモ |
---|
次のコード サンプルはシングルファイル コード モデルを使用しており、分離コード ファイルに直接コピーされた場合は正常に動作しない可能性があります。このコード サンプルは、拡張子が .aspx の空のテキスト ファイルにコピーする必要があります。Web フォームのコード モデルの詳細については、「ASP.NET Web ページのコード モデル」を参照してください。 |
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script runat="server"> Sub Page_Load(sender As Object, e As EventArgs) ' Show or Hide the Panel contents. If Check1.Checked Then Panel1.Visible = False Else Panel1.Visible = True End If ' Generate the Label controls. Dim numlabels As Integer = Int32.Parse(DropDown1.SelectedItem.Value) Dim i As Integer For i = 1 To numlabels Dim l As New Label() l.Text = "Label" + i.ToString() l.ID = "Label" + i.ToString() Panel1.Controls.Add(l) Panel1.Controls.Add(New LiteralControl("<br>")) Next i ' Generate the Textbox controls. Dim numtexts As Integer = Int32.Parse(DropDown2.SelectedItem.Value) For i = 1 To numtexts Dim t As New TextBox() t.Text = "TextBox" & i.ToString() t.ID = "TextBox" & i.ToString() Panel1.Controls.Add(t) Panel1.Controls.Add(New LiteralControl("<br>")) Next i End Sub </script> </head> <body> <h3>Panel Example</h3> <form runat=server> <asp:Panel id="Panel1" runat="server" BackColor="gainsboro" Height="200px" Width="300px"> Panel1: Here is some static content... <p> </asp:Panel> <p> Generate Labels: <asp:DropDownList id=DropDown1 runat="server"> <asp:ListItem Value="0">0</asp:ListItem> <asp:ListItem Value="1">1</asp:ListItem> <asp:ListItem Value="2">2</asp:ListItem> <asp:ListItem Value="3">3</asp:ListItem> <asp:ListItem Value="4">4</asp:ListItem> </asp:DropDownList> <br> Generate TextBoxes: <asp:DropDownList id=DropDown2 runat="server"> <asp:ListItem Value="0">0</asp:ListItem> <asp:ListItem Value="1">1</asp:ListItem> <asp:ListItem Value="2">2</asp:ListItem> <asp:ListItem Value="3">3</asp:ListItem> <asp:ListItem Value="4">4</asp:ListItem> </asp:DropDownList> <p> <asp:CheckBox id="Check1" Text="Hide Panel" runat="server"/> <p> <asp:Button Text="Refresh Panel" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script runat="server"> void Page_Load(Object sender, EventArgs e) { // Show or hide the Panel contents. if (Check1.Checked) { Panel1.Visible=false; } else { Panel1.Visible=true; } // Generate the Label controls. int numlabels = Int32.Parse(DropDown1.SelectedItem.Value); for (int i=1; i<=numlabels; i++) { Label l = new Label(); l.Text = "Label" + (i).ToString(); l.ID = "Label" + (i).ToString(); Panel1.Controls.Add(l); Panel1.Controls.Add(new LiteralControl("<br>")); } // Generate the Textbox controls. int numtexts = Int32.Parse(DropDown2.SelectedItem.Value); for (int i=1; i<=numtexts; i++) { TextBox t = new TextBox(); t.Text = "TextBox" + (i).ToString(); t.ID = "TextBox" + (i).ToString(); Panel1.Controls.Add(t); Panel1.Controls.Add(new LiteralControl("<br>")); } } </script> </head> <body> <h3>Panel Example</h3> <form runat=server> <asp:Panel id="Panel1" runat="server" BackColor="gainsboro" Height="200px" Width="300px"> Panel1: Here is some static content... <p> </asp:Panel> <p> Generate Labels: <asp:DropDownList id=DropDown1 runat="server"> <asp:ListItem Value="0">0</asp:ListItem> <asp:ListItem Value="1">1</asp:ListItem> <asp:ListItem Value="2">2</asp:ListItem> <asp:ListItem Value="3">3</asp:ListItem> <asp:ListItem Value="4">4</asp:ListItem> </asp:DropDownList> <br> Generate TextBoxes: <asp:DropDownList id=DropDown2 runat="server"> <asp:ListItem Value="0">0</asp:ListItem> <asp:ListItem Value="1">1</asp:ListItem> <asp:ListItem Value="2">2</asp:ListItem> <asp:ListItem Value="3">3</asp:ListItem> <asp:ListItem Value="4">4</asp:ListItem> </asp:DropDownList> <p> <asp:CheckBox id="Check1" Text="Hide Panel" runat="server"/> <p> <asp:Button Text="Refresh Panel" runat="server"/> </form> </body> </html>
System.Web.UI.Control
System.Web.UI.WebControls.WebControl
System.Web.UI.WebControls.Panel
System.Web.UI.WebControls.WebParts.Part
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Panel クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ <ComVisibleAttribute(True)> _ Public Class Panel Inherits ScrollableControl
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] [ComVisibleAttribute(true)] public class Panel : ScrollableControl
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] [ComVisibleAttribute(true)] public ref class Panel : public ScrollableControl
Panel は、ほかのコントロールを格納するコントロールです。Panel を使用して、RadioButton コントロールのグループなど、複数のコントロールをまとめてグループ化できます。GroupBox コントロールなどのほかのコンテナ コントロールと同様に、Panel コントロールの Enabled プロパティが false に設定されている場合は、Panel に格納されているコントロールも無効になります。
既定では、Panel コントロールには境界線が表示されません。パネルの領域をフォーム上のほかの領域から区別するには、BorderStyle プロパティを使用して、標準の境界線または 3D 境界線を表示できます。Panel コントロールは ScrollableControl クラスから派生しているため、AutoScroll プロパティを使用して、Panel コントロールにスクロール バーを表示できます。AutoScroll プロパティが true に設定されている場合、表示されているスクロール バーを使用して、Panel の内側 (ただし表示領域の外側) にある任意のコントロールまでスクロールできます。
Panel コントロールにはキャプションが表示されません。キャプションを表示できる Panel のようなコントロールが必要な場合には、GroupBox コントロールのトピックを参照してください。
Panel コントロールを作成し、Label および TextBox を Panel に追加するコード例を次に示します。Panel コントロールは、Panel コントロールが位置する場所をフォーム上のほかのオブジェクトと区別するために 3D 境界線付きで表示されます。この例では、ここで定義されているメソッドが既存のフォーム内から呼び出され、System.Drawing 名前空間が、そのフォームのソース コードに追加されていることを前提にしています。
Public Sub CreateMyPanel() Dim panel1 As New Panel() Dim textBox1 As New TextBox() Dim label1 As New Label() ' Initialize the Panel control. panel1.Location = New Point(56, 72) panel1.Size = New Size(264, 152) ' Set the Borderstyle for the Panel to three-dimensional. panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D ' Initialize the Label and TextBox controls. label1.Location = New Point(16, 16) label1.Text = "label1" label1.Size = New Size(104, 16) textBox1.Location = New Point(16, 32) textBox1.Text = "" textBox1.Size = New Size(152, 20) ' Add the Panel control to the form. Me.Controls.Add(panel1) ' Add the Label and TextBox controls to the Panel. panel1.Controls.Add(label1) panel1.Controls.Add(textBox1) End Sub
public void CreateMyPanel() { Panel panel1 = new Panel(); TextBox textBox1 = new TextBox(); Label label1 = new Label(); // Initialize the Panel control. panel1.Location = new Point(56,72); panel1.Size = new Size(264, 152); // Set the Borderstyle for the Panel to three-dimensional. panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; // Initialize the Label and TextBox controls. label1.Location = new Point(16,16); label1.Text = "label1"; label1.Size = new Size(104, 16); textBox1.Location = new Point(16,32); textBox1.Text = ""; textBox1.Size = new Size(152, 20); // Add the Panel control to the form. this.Controls.Add(panel1); // Add the Label and TextBox controls to the Panel. panel1.Controls.Add(label1); panel1.Controls.Add(textBox1); }
public: void CreateMyPanel() { Panel^ panel1 = gcnew Panel; TextBox^ textBox1 = gcnew TextBox; Label^ label1 = gcnew Label; // Initialize the Panel control. panel1->Location = System::Drawing::Point( 56, 72 ); panel1->Size = System::Drawing::Size( 264, 152 ); // Set the Borderstyle for the Panel to three-dimensional. panel1->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D; // Initialize the Label and TextBox controls. label1->Location = System::Drawing::Point( 16, 16 ); label1->Text = "label1"; label1->Size = System::Drawing::Size( 104, 16 ); textBox1->Location = System::Drawing::Point( 16, 32 ); textBox1->Text = ""; textBox1->Size = System::Drawing::Size( 152, 20 ); // Add the Panel control to the form. this->Controls->Add( panel1 ); // Add the Label and TextBox controls to the Panel. panel1->Controls->Add( label1 ); panel1->Controls->Add( textBox1 ); }
public void CreateMyPanel() { Panel panel1 = new Panel(); TextBox textBox1 = new TextBox(); Label label1 = new Label(); // Initialize the Panel control. panel1.set_Location(new Point(56, 72)); panel1.set_Size(new Size(264, 152)); // Set the Borderstyle for the Panel to three-dimensional. panel1.set_BorderStyle(System.Windows.Forms.BorderStyle.Fixed3D); // Initialize the Label and TextBox controls. label1.set_Location(new Point(16, 16)); label1.set_Text("label1"); label1.set_Size(new Size(104, 16)); textBox1.set_Location(new Point(16, 32)); textBox1.set_Text(""); textBox1.set_Size(new Size(152, 20)); // Add the Panel control to the form. this.get_Controls().Add(panel1); // Add the Label and TextBox controls to the Panel. panel1.get_Controls().Add(label1); panel1.get_Controls().Add(textBox1); } //CreateMyPanel
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.ScrollableControl
System.Windows.Forms.Panel
派生クラス
プラットフォーム
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Weblioに収録されているすべての辞書からPanel クラスを検索する場合は、下記のリンクをクリックしてください。
全ての辞書からPanel クラスを検索
- Panel クラスのページへのリンク