using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace V9._PictureBox控件 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { //pictureBox控件可以用來(lái)顯示位圖,圖標(biāo)或元文件,以增強(qiáng)元文件 JPEG Gif 文件的圖形 //如果控件不足已顯示整幅圖像的 則裁剪圖像已適應(yīng)控件的大小 label3.Visible = false; label4.Visible = false; label5.Visible = false; label6.Visible = false; label7.Visible = false; } private void pictureBox2_Click(object sender, EventArgs e) { } private void radioButton1_CheckedChanged(object sender, EventArgs e) { pictureBox2.SizeMode = PictureBoxSizeMode.Normal; label3.Visible = true; label4.Visible = false; label5.Visible = false; label6.Visible = false; label7.Visible = false; } private void radioButton2_CheckedChanged(object sender, EventArgs e) { pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage ; label3.Visible = false; label4.Visible = true; label5.Visible = false; label6.Visible = false; label7.Visible = false; } private void radioButton3_CheckedChanged(object sender, EventArgs e) { pictureBox2.SizeMode = PictureBoxSizeMode.AutoSize ; label3.Visible = false; label4.Visible = false; label5.Visible = true; label6.Visible = false; label7.Visible = false; } private void radioButton4_CheckedChanged(object sender, EventArgs e) { pictureBox2.SizeMode = PictureBoxSizeMode.CenterImage; label3.Visible = false; label4.Visible = false; label5.Visible = false; label6.Visible = true; label7.Visible = false; } private void radioButton5_CheckedChanged(object sender, EventArgs e) { pictureBox2.SizeMode = PictureBoxSizeMode.Zoom; label3.Visible = false; label4.Visible = false; label5.Visible = false; label6.Visible = false; label7.Visible = true; } } } using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; namespace V9.__PictureBox控件_2__圖片瀏覽 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public int i = 0; //圖片索引參數(shù) public string[] path = Directory.GetFiles(@"D:\VS Projects\控制臺(tái)應(yīng)用程序\V9.2 PictureBox控件(2) 圖片瀏覽\Resources"); private void Form1_Load(object sender, EventArgs e) { //設(shè)置頂圖片如何在 picturebox 顯示 pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; //設(shè)定prctrueBox默認(rèn)圖像 pictureBox1.Image = Image.FromFile(@"D:\VS Projects\控制臺(tái)應(yīng)用程序\V9.2 PictureBox控件(2) 圖片瀏覽\Resources\Heke08313.png"); } private void btnFore_Click(object sender, EventArgs e) { i--; if (i < 0) i = path.Length - 1; //總長(zhǎng)-1 pictureBox1.Image = Image.FromFile(path[i]); } private void btnNext_Click(object sender, EventArgs e) { i++; if (i < 0) i =0; pictureBox1.Image = Image.FromFile(path[i]); } } } |
|