zoukankan      html  css  js  c++  java
  • Chapter 3. WinForm(PictureBox控件)

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    
    namespace 图片控件
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void pictureBox1_Click(object sender, EventArgs e)
            {
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                //设置图片显示方式:平铺
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                
                //获得指定一种图片的路径
                pictureBox1.Image = Image.FromFile(@"C:UsersAdministratorDesktop新建文件夹1.jpg");
            }
    
            int i = 0;
    
            //获得指定文件夹中的所有文件路径
            string[] path = Directory.GetFiles(@"C:UsersAdministratorDesktop新建文件夹");
    
            /// <summary>
            /// 点击更换下一张图片
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button2_Click(object sender, EventArgs e)
            {
                i++;
                if (i == path.Length)
                {
                    i = 0;
                }
                pictureBox1.Image = Image.FromFile(path[i]);
            }
    
            /// <summary>
            /// 点击更换上一张图片
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button1_Click(object sender, EventArgs e)
            {
                i--;
                if(i<0)
                {
                    i = path.Length - 1;
                }
                pictureBox1.Image = Image.FromFile(path[i]);
            }
        }
    }

  • 相关阅读:
    模拟手机售电影票
    flex布局
    如何制作快速加载的HTML页面
    css布局列表,自适应
    iOS项目中常见定时器
    iOS中TableView的分割线顶格样式的实现
    iOS本地化项目上传到gitHub
    iOS初学者易懵逼的Timer延时
    iOS同种界面moda和push方式切换
    iOS之push和modal大不同
  • 原文地址:https://www.cnblogs.com/xiao55/p/5630398.html
Copyright © 2011-2022 走看看