本文整理汇总了C#中System.Windows.Forms.PictureBox.BorderStyle属性的典型用法代码示例。如果您正苦于以下问题:C# PictureBox.BorderStyle属性的具体用法?C# PictureBox.BorderStyle怎么用?C# PictureBox.BorderStyle使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.PictureBox
的用法示例。
在下文中一共展示了PictureBox.BorderStyle属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateListView
private void PopulateListView()
{
ListView1.Width = 270;
ListView1.Location = new System.Drawing.Point(10, 10);
// Declare and construct the ColumnHeader objects.
ColumnHeader header1, header2;
header1 = new ColumnHeader();
header2 = new ColumnHeader();
// Set the text, alignment and width for each column header.
header1.Text = "File name";
header1.TextAlign = HorizontalAlignment.Left;
header1.Width = 70;
header2.TextAlign = HorizontalAlignment.Left;
header2.Text = "Location";
header2.Width = 200;
// Add the headers to the ListView control.
ListView1.Columns.Add(header1);
ListView1.Columns.Add(header2);
// Specify that each item appears on a separate line.
ListView1.View = View.Details;
// Populate the ListView.Items property.
// Set the directory to the sample picture directory.
System.IO.DirectoryInfo dirInfo =
new System.IO.DirectoryInfo(
"C:\\Documents and Settings\\All Users" +
"\\Documents\\My Pictures\\Sample Pictures");
// Get the .jpg files from the directory
System.IO.FileInfo[] files = dirInfo.GetFiles("*.jpg");
// Add each file name and full name including path
// to the ListView.
if (files != null)
{
foreach ( System.IO.FileInfo file in files )
{
ListViewItem item = new ListViewItem(file.Name);
item.SubItems.Add(file.FullName);
ListView1.Items.Add(item);
}
}
}
private void InitializePictureBox()
{
PictureBox1 = new PictureBox();
// Set the location and size of the PictureBox control.
this.PictureBox1.Location = new System.Drawing.Point(70, 120);
this.PictureBox1.Size = new System.Drawing.Size(140, 140);
this.PictureBox1.TabStop = false;
// Set the SizeMode property to the StretchImage value. This
// will shrink or enlarge the image as needed to fit into
// the PictureBox.
this.PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
// Set the border style to a three-dimensional border.
this.PictureBox1.BorderStyle = BorderStyle.Fixed3D;
// Add the PictureBox to the form.
this.Controls.Add(this.PictureBox1);
}
private void ListView1_MouseDown(object sender, MouseEventArgs e)
{
ListViewItem selection = ListView1.GetItemAt(e.X, e.Y);
// If the user selects an item in the ListView, display
// the image in the PictureBox.
if (selection != null)
{
PictureBox1.Image = System.Drawing.Image.FromFile(
selection.SubItems[1].Text);
}
}
示例2: PictureBoxTest
//引入命名空间
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
public class PictureBoxTest : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox imagePictureBox;
private System.Windows.Forms.Label promptLabel;
public PictureBoxTest()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.promptLabel = new System.Windows.Forms.Label();
this.imagePictureBox = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
this.promptLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.promptLabel.Location = new System.Drawing.Point(22, 8);
this.promptLabel.Name = "promptLabel";
this.promptLabel.Size = new System.Drawing.Size(124, 56);
this.promptLabel.TabIndex = 0;
this.promptLabel.Text = "Click On PictureBox to View Images";
this.promptLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.imagePictureBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.imagePictureBox.Location = new System.Drawing.Point(34, 72);
this.imagePictureBox.Name = "imagePictureBox";
this.imagePictureBox.Size = new System.Drawing.Size(100, 100);
this.imagePictureBox.TabIndex = 1;
this.imagePictureBox.TabStop = false;
this.imagePictureBox.Click += new System.EventHandler(this.imagePictureBox_Click );
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(168, 189);
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.imagePictureBox,
this.promptLabel});
this.Text = "PictureBoxTest";
this.ResumeLayout(false);
}
[STAThread]
static void Main()
{
Application.Run( new PictureBoxTest() );
}
private void imagePictureBox_Click(object sender, System.EventArgs e )
{
imagePictureBox.Image = Image.FromFile(Directory.GetCurrentDirectory() + "\\winter.jpg" );
}
}