数字调节控件

--pictureBox--支持静态的图像格式

image属性导入一张图片

--imageLocation属性--也可以导入图片

url地址就可

可以改变

使图像填充正确

-----NumericUpDown-----

 

--ProgressBar---进度条

 

--value仅显示进度条外观,没有实际意义

---step步进条

---timer---没有外观

--间隔--ms为单位

 

编写实例:

加载窗体

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication2_Csharp
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void progressBar1_Click(object sender, EventArgs e)
        {

        }

        private void Form3_Load(object sender, EventArgs e)
        {
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            pictureBox1.ImageLocation = @"D:\9宫格.png";
        }
    }
}

加载窗口时指定位置的图片

---实现timer控件获取图片加载的时间并设置到进度条上显示

1.timer控件的启动--button

2.添加根据timer时间控件所增加的进度条

3.设置numericUpDown来调节增加进度条的

 

b必须加控制语句来控制进度条,不然会出现异常

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication2_Csharp
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void progressBar1_Click(object sender, EventArgs e)
        {

        }

        private void Form3_Load(object sender, EventArgs e)
        {
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            pictureBox1.ImageLocation = @"D:\9宫格.png";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Enabled = true;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            var incr = Convert.ToInt32(numericUpDown1.Value);
            //progressBar1.Value++;
            if (progressBar1.Value + incr <= progressBar1.Maximum)
                progressBar1.Value += Convert.ToInt32(numericUpDown1.Value);
            else
                progressBar1.Value = Convert.ToInt32(progressBar1.Maximum);
        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {

        }
    }
}

----切换图像----

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication2_Csharp
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void progressBar1_Click(object sender, EventArgs e)
        {

        }

        private void Form3_Load(object sender, EventArgs e)
        {
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            pictureBox1.ImageLocation = @"D:\9宫格.png";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Enabled = true;
        }
        int index;//切换索引
        private void timer1_Tick(object sender, EventArgs e)
        {
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;

 /*           var incr = Convert.ToInt32(numericUpDown1.Value);
            //progressBar1.Value++;
            if (progressBar1.Value + incr <= progressBar1.Maximum)
                progressBar1.Value += Convert.ToInt32(numericUpDown1.Value);
            else
                progressBar1.Value = Convert.ToInt32(progressBar1.Maximum);
  */       //每隔四秒
            index = (index + 1) % 4;
            switch (index)
            {
                case 0:
                    pictureBox1.ImageLocation = @"D:\9宫格.png";
                    break;
                case 1:
                    pictureBox1.ImageLocation = @"D:\1.png";
                    break;
                case 2:
                    pictureBox1.ImageLocation = @"D:\2.png";
                    break;
                case 3:
                    pictureBox1.ImageLocation = @"D:\3.png";
                    break;
                

            }
        
        
        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {

        }
    }
}

---换一个环境 图片加载失败问题,可以用属性图片资源加载图片解决---

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication2_Csharp
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void progressBar1_Click(object sender, EventArgs e)
        {

        }

        private void Form3_Load(object sender, EventArgs e)
        {
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            pictureBox1.ImageLocation = @"D:\9宫格.png";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Enabled = true;
        }
        int index;//切换索引
        private void timer1_Tick(object sender, EventArgs e)
        {
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;

 /*           var incr = Convert.ToInt32(numericUpDown1.Value);
            //progressBar1.Value++;
            if (progressBar1.Value + incr <= progressBar1.Maximum)
                progressBar1.Value += Convert.ToInt32(numericUpDown1.Value);
            else
                progressBar1.Value = Convert.ToInt32(progressBar1.Maximum);
  */       //每隔四秒
            index = (index + 1) % 4;
            switch (index)
            {
                case 0:
                    pictureBox1.Image = Properties.Resources._9宫格;
                   // pictureBox1.ImageLocation = @"D:\9宫格.png";
                    break;
                case 1:
                    pictureBox1.Image = Properties.Resources._1;
                   // pictureBox1.ImageLocation = @"D:\1.png";
                    break;
                case 2:
                    pictureBox1.Image = Properties.Resources._2;
                    //pictureBox1.ImageLocation = @"D:\2.png";
                    break;
                case 3:
                    pictureBox1.Image = Properties.Resources._3;
                   // pictureBox1.ImageLocation = @"D:\3.png";
                    break;
            }
        
        
        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {

        }
    }
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值