c#窗体显示图片的控件picturebox_imagelist_image

 private void Form2_Load(object sender, EventArgs e)
        {
            dataGridView1.AllowUserToAddRows = true;
            //如果选中DATAGRIDVIEW某行其中某个单元格(列)是空值,进行相应的特殊处理
            //data source,user id,password不区分大小写
            OracleConnection con = new OracleConnection("data Source=orcl;user id=scott;password=system");
            OracleCommand comm = new OracleCommand();
            comm.Connection = con;
            comm.CommandText = "select deptno,dname,loc from dept";
            comm.CommandType = CommandType.Text;
            da= new OracleDataAdapter(comm);
            ds1 = new DataSet();
            oda.Fill(ds1);
            dataGridView1.DataSource = ds1.Tables[0];

            //学习显示图像控件的相关用法
            //要显示的图像资源
            // 因为在C# \是特殊字符,为了显示它,用转义字符\\表示\

            //Bitmap image1 = (Bitmap)Image.FromFile(@"image1.bmp", true);
            //要显示的图像资源,fromfile表示自什么地方创建图像资源,true表示使用图像文件的颜色管理方案
            Image image1 = Image.FromFile(@"f:\image1.bmp",true);
           
            //Image im = Image.FromFile(@"f:\image.bmp",true);
            //imagelist是个装载多个图像image的控件,显示图像控件是picturebox,它显示的图像源于imagelist中某个image
            imageList1.Images.Add(image1);
            //imagelist.imagesize为图像集中每个图像的大小
            imageList1.ImageSize = new Size(250,250);
            pictureBox1.Image = imageList1.Images[0];

        }

 

示例代码运行结果:

 

 

 

9240380_201202290018441.jpg

fj.pngimage1.JPG

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9240380/viewspace-717325/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9240380/viewspace-717325/

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值