using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form {
Font textFont = new Font("Times New Roman", 24);
public Form1() {
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
this.panel1.AutoScroll = true;
this.panel1.AutoScrollMinSize = new System.Drawing.Size(600, 400);
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Location = new System.Drawing.Point(13, 13);
this.panel1.Size = new System.Drawing.Size(267, 243);
this.pictureBox1.BackColor = System.Drawing.SystemColors.Window;
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Size = new System.Drawing.Size(600, 400);
this.pictureBox1.TabStop = false;
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 268);
this.Controls.Add(this.panel1);
this.Load += new System.EventHandler(this.Form1_Load);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
}
private void Form1_Load(object sender, EventArgs e) {
Bitmap b = new Bitmap(600, 600);
Graphics g = Graphics.FromImage(b);
g.FillRectangle(Brushes.White, new Rectangle(0, 0, b.Width, b.Height));
g.DrawString("Hello, World", textFont, Brushes.Black, 40, 40);
g.DrawString("Hello, World", textFont, Brushes.Red, 40, 240);
g.DrawString("Hello, World", textFont, Brushes.Blue, 350, 40);
g.DrawString("Hello, World", textFont, Brushes.Green, 350, 240);
pictureBox1.BackgroundImage = b;
pictureBox1.Size = b.Size;
}
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.Run(new Form1());
}
}
PictureBox visible and invisible
using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class ListText : Form {
private Button choose = new Button();
private ListBox animalList = new ListBox( );
private ListBox things = new ListBox( );
private TextBox text = new TextBox( );
private PictureBox picture = new PictureBox();
private PictureBox photo = new PictureBox();
private CheckBox show = new CheckBox();
private CheckBox author = new CheckBox();
private Bitmap moon = new Bitmap(“winter.jpg”);
public ListText( ) {
Text = “List Text”;
choose.Text = “Choose”;
show.Text = “Show a bitmap”;
author.Text = “Show another bitmap”;
Size = new Size(400, 300);
choose.Size = new Size(100,20);
text.Size = new Size(150,50);
photo.Size = new Size(100,100);
choose.Location = new Point(20,30);
animalList.Location = new Point(30 + choose.Width, 30);
things.Location = new Point(40 + choose.Width + animalList.Width, 30);
text.Location = new Point(20, 150);
photo.Location = new Point(40 + text.Width, 150);
picture.Location = new Point(60 + text.Width + photo.Width, 150);
show.Location = new Point(20,70);
author.Location = new Point(20,110);
animalList.SelectionMode = SelectionMode.MultiSimple;
things.SelectionMode = SelectionMode.One;
text.Multiline = true;
picture.Image = (Image)moon;
picture.Visible = false;
photo.Image = Image.FromFile(“winter.jpg”);
photo.Visible = false;
BackColor = Color.White;
choose.BackColor = Color.Pink;
animalList.Items.Add(“A”);
animalList.Items.Add(“B”);
animalList.Items.Add(“C”);
animalList.Items.Add(“D”);
animalList.Items.Add(“E”);
things.Items.Add(“1”);
things.Items.Add(“2”);
things.Items.Add(“3”);
things.Items.Add(“4”);
Controls.Add(animalList);
Controls.Add(things);
Controls.Add(choose);
Controls.Add(text);
Controls.Add(picture);
Controls.Add(show);
Controls.Add(author);
Controls.Add(photo);
choose.Click += new EventHandler(Choose_Click);
things.SelectedIndexChanged += new EventHandler(Things_Changed);
show.CheckedChanged += new EventHandler(Picture_Changed);
author.CheckedChanged += new EventHandler(Photo_Changed);
}
protected void Choose_Click(object sender, EventArgs e) {
for(int i = 0; i < animalList.SelectedItems.Count; i++){
Console.WriteLine(animalList.SelectedItems[i].ToString());
}
}
protected void Things_Changed(object sender, EventArgs e) {
text.Text = "You selected " + things.SelectedItem;
}
protected void Picture_Changed(Object sender, EventArgs e) {
if (show.Checked)
picture.Visible = true;
else
picture.Visible = false;
Invalidate();
}
protected void Photo_Changed(Object sender, EventArgs e) {
if (author.Checked)
photo.Visible = true;
else
photo.Visible = false;
Invalidate();
}
static void Main() {
Application.Run(new ListText());
}
}
[/csharp]
PictureBox Demo
/*
Professional Windows GUI Programming Using C#
by Jay Glynn, Csaba Torok, Richard Conway, Wahid Choudhury,
Zach Greenvoss, Shripad Kulkarni, Neil Whitlow
Publisher: Peer Information
ISBN: 1861007663
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace BictureBox
{
/// <summary>
/// Summary description for PictureBoxDemo.
/// </summary>
public class PictureBoxDemo : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.PictureBox pictureBox3;
private System.Windows.Forms.PictureBox pictureBox4;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public PictureBoxDemo()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.Text = "SizeMode in PictureBox";
this.button1.Text = "Display";
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.pictureBox4 = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pictureBox1.Location = new System.Drawing.Point(8, 8);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(100, 70);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// button1
//
this.button1.Location = new System.Drawing.Point(232, 24);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(56, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// pictureBox2
//
this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pictureBox2.Location = new System.Drawing.Point(120, 8);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(100, 70);
this.pictureBox2.TabIndex = 0;
this.pictureBox2.TabStop = false;
//
// pictureBox3
//
this.pictureBox3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pictureBox3.Location = new System.Drawing.Point(8, 88);
this.pictureBox3.Name = "pictureBox3";
this.pictureBox3.Size = new System.Drawing.Size(100, 70);
this.pictureBox3.TabIndex = 0;
this.pictureBox3.TabStop = false;
//
// pictureBox4
//
this.pictureBox4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pictureBox4.Location = new System.Drawing.Point(120, 88);
this.pictureBox4.Name = "pictureBox4";
this.pictureBox4.Size = new System.Drawing.Size(100, 70);
this.pictureBox4.TabIndex = 0;
this.pictureBox4.TabStop = false;
//
// PictureBoxDemo
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(376, 254);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1,
this.pictureBox2,
this.pictureBox3,
this.pictureBox4,
this.pictureBox1});
this.Name = "PictureBoxDemo";
this.Text = "PictureBoxDemo";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new PictureBoxDemo());
}
private void button1_Click(object sender, System.EventArgs e)
{
SetPictureBoxSizeMode();
}
private void SetPictureBoxSizeMode()
{
string path = @"Dobos3.BMP"; // Change the path if needed.
pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
pictureBox1.Image = Image.FromFile(path);
pictureBox2.SizeMode = PictureBoxSizeMode.Normal;
pictureBox2.Image = Image.FromFile(path);
pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox3.Image = Image.FromFile(path);
pictureBox4.SizeMode = PictureBoxSizeMode.AutoSize;
pictureBox4.Image = Image.FromFile(path);
}
}
}
P17_PictureBox.zip( 103 k)
SizeMode in PictureBox
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
public class Form1 : System.Windows.Forms.Form {
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.PictureBox pictureBox3;
private System.Windows.Forms.PictureBox pictureBox4;
public Form1() {
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.pictureBox4 = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pictureBox1.Location = new System.Drawing.Point(8, 8);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(100, 70);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// button1
//
this.button1.Location = new System.Drawing.Point(232, 24);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(56, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// pictureBox2
//
this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pictureBox2.Location = new System.Drawing.Point(120, 8);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(100, 70);
this.pictureBox2.TabIndex = 0;
this.pictureBox2.TabStop = false;
//
// pictureBox3
//
this.pictureBox3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pictureBox3.Location = new System.Drawing.Point(8, 88);
this.pictureBox3.Name = "pictureBox3";
this.pictureBox3.Size = new System.Drawing.Size(100, 70);
this.pictureBox3.TabIndex = 0;
this.pictureBox3.TabStop = false;
//
// pictureBox4
//
this.pictureBox4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pictureBox4.Location = new System.Drawing.Point(120, 88);
this.pictureBox4.Name = "pictureBox4";
this.pictureBox4.Size = new System.Drawing.Size(100, 70);
this.pictureBox4.TabIndex = 0;
this.pictureBox4.TabStop = false;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(376, 254);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1,
this.pictureBox2,
this.pictureBox3,
this.pictureBox4,
this.pictureBox1});
this.ResumeLayout(false);
this.button1.Text = "Display";
}
[STAThread]
static void Main() {
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e) {
SetPictureBoxSizeMode();
}
private void SetPictureBoxSizeMode() {
string path = "3.BMP"; // Change the path if needed.
pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
pictureBox1.Image = Image.FromFile(path);
pictureBox2.SizeMode = PictureBoxSizeMode.Normal;
pictureBox2.Image = Image.FromFile(path);
pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox3.Image = Image.FromFile(path);
pictureBox4.SizeMode = PictureBoxSizeMode.AutoSize;
pictureBox4.Image = Image.FromFile(path);
}
}
Subclass PictureBox
using System;
using System.Drawing;
using System.Windows.Forms;
class PictureBoxPlusDemo: Form
{
public static void Main()
{
Application.Run(new PictureBoxPlusDemo());
}
public PictureBoxPlusDemo()
{
Text = "PictureBoxPlus Demo";
PictureBoxPlus picbox = new PictureBoxPlus();
picbox.Parent = this;
picbox.Dock = DockStyle.Fill;
picbox.Image = Image.FromFile("Color.jpg");
}
}
class PictureBoxPlus: PictureBox
{
protected override void OnPaint(PaintEventArgs pea)
{
ScaleImageIsotropically(pea.Graphics, Image,ClientRectangle);
}
void ScaleImageIsotropically(Graphics grfx, Image image,
Rectangle rect)
{
SizeF sizef =
new SizeF(image.Width / image.HorizontalResolution,
image.Height / image.VerticalResolution);
float fScale = Math.Min(rect.Width / sizef.Width,
rect.Height / sizef.Height);
sizef.Width *= fScale;
sizef.Height *= fScale;
grfx.DrawImage(image,
rect.X + (rect.Width - sizef.Width ) / 2,
rect.Y + (rect.Height - sizef.Height) / 2,
sizef.Width, sizef.Height);
}
}
Split Container(Panel): Collapsed
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form
{
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.SplitContainer splitContainer2;
private System.Windows.Forms.WebBrowser webBrowser1;
private System.Windows.Forms.TextBox TextBox1;
private System.Windows.Forms.Panel pnlFileList;
private System.Windows.Forms.Button cmdHide;
private System.Windows.Forms.ListView ListView1;
private System.Windows.Forms.ColumnHeader ColumnHeader1;
private System.Windows.Forms.Panel pnlShow;
private System.Windows.Forms.Button cmdShow;
public Form1() {
InitializeComponent();
ListView1.Items.Add("A");
ListView1.Items.Add("B");
ListView1.Items.Add("C");
}
private void cmdHide_Click(object sender, EventArgs e)
{
splitContainer1.Panel1Collapsed = true;
pnlShow.Visible = true;
}
private void cmdShow_Click(object sender, EventArgs e)
{
splitContainer1.Panel1Collapsed = false;
pnlShow.Visible = false;
}
private void InitializeComponent()
{
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.pnlFileList = new System.Windows.Forms.Panel();
this.cmdHide = new System.Windows.Forms.Button();
this.ListView1 = new System.Windows.Forms.ListView();
this.ColumnHeader1 = new System.Windows.Forms.ColumnHeader();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.webBrowser1 = new System.Windows.Forms.WebBrowser();
this.TextBox1 = new System.Windows.Forms.TextBox();
this.pnlShow = new System.Windows.Forms.Panel();
this.cmdShow = new System.Windows.Forms.Button();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.pnlFileList.SuspendLayout();
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout();
this.pnlShow.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(29, 10);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.pnlFileList);
this.splitContainer1.Panel1MinSize = 50;
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
this.splitContainer1.Size = new System.Drawing.Size(477, 366);
this.splitContainer1.SplitterDistance = 155;
this.splitContainer1.TabIndex = 0;
this.splitContainer1.Text = "splitContainer1";
//
// pnlFileList
//
this.pnlFileList.Controls.Add(this.cmdHide);
this.pnlFileList.Controls.Add(this.ListView1);
this.pnlFileList.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlFileList.Location = new System.Drawing.Point(0, 0);
this.pnlFileList.Name = "pnlFileList";
this.pnlFileList.Padding = new System.Windows.Forms.Padding(0, 0, 1, 0);
this.pnlFileList.Size = new System.Drawing.Size(155, 366);
this.pnlFileList.TabIndex = 21;
//
// cmdHide
//
this.cmdHide.Dock = System.Windows.Forms.DockStyle.Bottom;
this.cmdHide.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cmdHide.Location = new System.Drawing.Point(0, 346);
this.cmdHide.Name = "cmdHide";
this.cmdHide.Size = new System.Drawing.Size(154, 20);
this.cmdHide.TabIndex = 23;
this.cmdHide.Text = "<< Hide";
this.cmdHide.Click += new System.EventHandler(this.cmdHide_Click);
//
// ListView1
//
this.ListView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.ListView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.ColumnHeader1});
this.ListView1.Location = new System.Drawing.Point(0, 3);
this.ListView1.Name = "ListView1";
this.ListView1.Size = new System.Drawing.Size(152, 337);
this.ListView1.TabIndex = 22;
this.ListView1.UseCompatibleStateImageBehavior = false;
this.ListView1.View = System.Windows.Forms.View.Details;
//
// ColumnHeader1
//
this.ColumnHeader1.Name = "ColumnHeader1";
this.ColumnHeader1.Text = "File";
this.ColumnHeader1.Width = 99;
//
// splitContainer2
//
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer2.Location = new System.Drawing.Point(0, 0);
this.splitContainer2.Name = "splitContainer2";
this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer2.Panel1
//
this.splitContainer2.Panel1.Controls.Add(this.webBrowser1);
//
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.TextBox1);
this.splitContainer2.Size = new System.Drawing.Size(318, 366);
this.splitContainer2.SplitterDistance = 173;
this.splitContainer2.TabIndex = 0;
this.splitContainer2.Text = "splitContainer2";
//
// webBrowser1
//
this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;
this.webBrowser1.Location = new System.Drawing.Point(0, 0);
this.webBrowser1.Name = "webBrowser1";
this.webBrowser1.Size = new System.Drawing.Size(318, 173);
this.webBrowser1.TabIndex = 0;
//
// TextBox1
//
this.TextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.TextBox1.Location = new System.Drawing.Point(0, 0);
this.TextBox1.Multiline = true;
this.TextBox1.Name = "TextBox1";
this.TextBox1.ReadOnly = true;
this.TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.TextBox1.Size = new System.Drawing.Size(318, 189);
this.TextBox1.TabIndex = 1;
//
// pnlShow
//
this.pnlShow.Controls.Add(this.cmdShow);
this.pnlShow.Dock = System.Windows.Forms.DockStyle.Left;
this.pnlShow.Location = new System.Drawing.Point(10, 10);
this.pnlShow.Name = "pnlShow";
this.pnlShow.Padding = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.pnlShow.Size = new System.Drawing.Size(19, 366);
this.pnlShow.TabIndex = 23;
this.pnlShow.Visible = false;
//
// cmdShow
//
this.cmdShow.Dock = System.Windows.Forms.DockStyle.Fill;
this.cmdShow.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cmdShow.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.cmdShow.Location = new System.Drawing.Point(0, 0);
this.cmdShow.Name = "cmdShow";
this.cmdShow.Size = new System.Drawing.Size(16, 366);
this.cmdShow.TabIndex = 21;
this.cmdShow.Text = ">";
this.cmdShow.Click += new System.EventHandler(this.cmdShow_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(516, 386);
this.Controls.Add(this.splitContainer1);
this.Controls.Add(this.pnlShow);
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "Form1";
this.Padding = new System.Windows.Forms.Padding(10);
this.Text = "Split Window";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.ResumeLayout(false);
this.pnlFileList.ResumeLayout(false);
this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel2.ResumeLayout(false);
this.splitContainer2.Panel2.PerformLayout();
this.splitContainer2.ResumeLayout(false);
this.pnlShow.ResumeLayout(false);
this.ResumeLayout(false);
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
}
Scrollable Panel
/*
User Interfaces in C#: Windows Forms and Custom Controls
by Matthew MacDonald
Publisher: Apress
ISBN: 1590590457
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace UnsualScrolling
{
/// <summary>
/// Summary description for ScrollablePanel.
/// </summary>
public class ScrollablePanel : System.Windows.Forms.Form
{
internal System.Windows.Forms.Panel Panel1;
internal System.Windows.Forms.Button Button6;
internal System.Windows.Forms.Button Button5;
internal System.Windows.Forms.Button Button4;
internal System.Windows.Forms.Button Button3;
internal System.Windows.Forms.Button Button2;
internal System.Windows.Forms.Button Button1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public ScrollablePanel()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Panel1 = new System.Windows.Forms.Panel();
this.Button6 = new System.Windows.Forms.Button();
this.Button5 = new System.Windows.Forms.Button();
this.Button4 = new System.Windows.Forms.Button();
this.Button3 = new System.Windows.Forms.Button();
this.Button2 = new System.Windows.Forms.Button();
this.Button1 = new System.Windows.Forms.Button();
this.Panel1.SuspendLayout();
this.SuspendLayout();
//
// Panel1
//
this.Panel1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.Panel1.AutoScroll = true;
this.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.Panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.Button6,
this.Button5,
this.Button4,
this.Button3,
this.Button2,
this.Button1});
this.Panel1.Location = new System.Drawing.Point(4, 8);
this.Panel1.Name = "Panel1";
this.Panel1.Size = new System.Drawing.Size(348, 172);
this.Panel1.TabIndex = 2;
//
// Button6
//
this.Button6.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.Button6.Location = new System.Drawing.Point(16, 180);
this.Button6.Name = "Button6";
this.Button6.Size = new System.Drawing.Size(168, 24);
this.Button6.TabIndex = 5;
this.Button6.Text = "Button6";
//
// Button5
//
this.Button5.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.Button5.Location = new System.Drawing.Point(16, 148);
this.Button5.Name = "Button5";
this.Button5.Size = new System.Drawing.Size(168, 24);
this.Button5.TabIndex = 4;
this.Button5.Text = "Button5";
//
// Button4
//
this.Button4.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.Button4.Location = new System.Drawing.Point(16, 116);
this.Button4.Name = "Button4";
this.Button4.Size = new System.Drawing.Size(168, 24);
this.Button4.TabIndex = 3;
this.Button4.Text = "Button4";
//
// Button3
//
this.Button3.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.Button3.Location = new System.Drawing.Point(16, 84);
this.Button3.Name = "Button3";
this.Button3.Size = new System.Drawing.Size(168, 24);
this.Button3.TabIndex = 2;
this.Button3.Text = "Button3";
//
// Button2
//
this.Button2.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.Button2.Location = new System.Drawing.Point(16, 52);
this.Button2.Name = "Button2";
this.Button2.Size = new System.Drawing.Size(168, 24);
this.Button2.TabIndex = 1;
this.Button2.Text = "Button2";
//
// Button1
//
this.Button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.Button1.Location = new System.Drawing.Point(16, 20);
this.Button1.Name = "Button1";
this.Button1.Size = new System.Drawing.Size(168, 24);
this.Button1.TabIndex = 0;
this.Button1.Text = "Button1";
//
// ScrollablePanel
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
this.ClientSize = new System.Drawing.Size(360, 194);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.Panel1});
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.Name = "ScrollablePanel";
this.Text = "Scrollable Panel";
this.Panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
static void Main()
{
Application.Run(new ScrollablePanel());
}
}
}

