zoukankan      html  css  js  c++  java
  • winform学习之----图片控件应用(上一张,下一张)

    示例1:   

            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]);
                
            }
            //上一张图片
            private void button1_Click(object sender, EventArgs e)
            {
                i--;
                if (i < 0)
                {
                    i = path.Length - 1;
                }
                pictureBox1.Image = Image.FromFile(path[i]);
            }

    示例2:

           利用计时器,随机数,每隔段时间就更新图片

            int i = 0;
            string[] path = Directory.GetFiles(@"C:UsersAdministratorDesktop图片");
            Random r = new Random();
            private void timer_click()
            {
                i++;
                if(i==path.length)
               {
                    i=0;
               }
               picturebox1.Image = Image.FormFile(path(r.Next(0,path.Length)));
           }         
    
  • 相关阅读:
    OpenCV --- 2.4.8组件结构全解析
    综合博客
    设计模式之适配器模式
    android 面试题
    ANDROID 中设计模式的采用--结构型模式
    技术前线
    八大排序算法
    android 面试题
    Android控件——ViewPager
    Bugly
  • 原文地址:https://www.cnblogs.com/candyzhmm/p/5532664.html
Copyright © 2011-2022 走看看