c#中关于picturebox和imagelist组件应用的问题
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Da...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace picturebox
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
imageList1.ColorDepth = ColorDepth.Depth32Bit;
}
private void button1_Click(object sender, EventArgs e)
{
imageList1.Images.Clear();
string path = "1.jpg";
Image img = Image.FromFile(path,true);
imageList1.Images.Add(img);
imageList1.ImageSize=new Size(215,135);
pictureBox1.Image=imageList1.Images[1];
}
private void button2_Click(object sender, EventArgs e)
{
imageList1.Images.Clear();
string Path = "2.jpg";
Image img = Image.FromFile(Path, true);
imageList1.Images.Add(img);
imageList1.ImageSize = new Size(215,135);
pictureBox1.Image = imageList1.Images[1];
}
private void button3_Click(object sender, EventArgs e)
{
imageList1.Images.RemoveAt(0);
pictureBox1.Image = null;
}
}
}
这是书上的一个关于picture控件应用的小程序编译不报错但是运行后点BUTTON后无响应,图片有放在DEbug中
无响应就是程序卡死那种!CPU一直在50% 展开
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace picturebox
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
imageList1.ColorDepth = ColorDepth.Depth32Bit;
}
private void button1_Click(object sender, EventArgs e)
{
imageList1.Images.Clear();
string path = "1.jpg";
Image img = Image.FromFile(path,true);
imageList1.Images.Add(img);
imageList1.ImageSize=new Size(215,135);
pictureBox1.Image=imageList1.Images[1];
}
private void button2_Click(object sender, EventArgs e)
{
imageList1.Images.Clear();
string Path = "2.jpg";
Image img = Image.FromFile(Path, true);
imageList1.Images.Add(img);
imageList1.ImageSize = new Size(215,135);
pictureBox1.Image = imageList1.Images[1];
}
private void button3_Click(object sender, EventArgs e)
{
imageList1.Images.RemoveAt(0);
pictureBox1.Image = null;
}
}
}
这是书上的一个关于picture控件应用的小程序编译不报错但是运行后点BUTTON后无响应,图片有放在DEbug中
无响应就是程序卡死那种!CPU一直在50% 展开
2个回答
展开全部
private void button1_Click(object sender, EventArgs e)
{
imageList1.Images.Clear();
string path = "1.jpg";
Image img = Image.FromFile(path,true);
imageList1.Images.Add(img);
imageList1.ImageSize=new Size(215,135);
pictureBox1.Image=imageList1.Images[0]; //注意这里的索引
}
private void button2_Click(object sender, EventArgs e)
{
imageList1.Images.Clear();
string Path = "2.jpg";
Image img = Image.FromFile(Path, true);
imageList1.Images.Add(img);
imageList1.ImageSize = new Size(215,135);
pictureBox1.Image = imageList1.Images[0];//注意这里的索引
}
{
imageList1.Images.Clear();
string path = "1.jpg";
Image img = Image.FromFile(path,true);
imageList1.Images.Add(img);
imageList1.ImageSize=new Size(215,135);
pictureBox1.Image=imageList1.Images[0]; //注意这里的索引
}
private void button2_Click(object sender, EventArgs e)
{
imageList1.Images.Clear();
string Path = "2.jpg";
Image img = Image.FromFile(Path, true);
imageList1.Images.Add(img);
imageList1.ImageSize = new Size(215,135);
pictureBox1.Image = imageList1.Images[0];//注意这里的索引
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
多半是按键没绑定
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询