C#动态生成PictureBox并指定图片的方法
本文实例讲述了C#动态生成PictureBox并指定图片的方法。分享给大家供大家参考。具体如下:
int Num = 0;
PictureBox[] pb;
Num = 6;
pb = new PictureBox[Num];
for (int i = 1; i < Num; i++)
{
pb[i] = new System.Windows.Forms.PictureBox();
pb[i].BorderStyle = BorderStyle.FixedSingle;
pb[i].Location = new Point(50 + i * 110, 100);
pb[i].SizeMode = PictureBoxSizeMode.Zoom;
pb[i].Image = Image.FromFile(@"D:\pic\" + i + ".png");
FlowPanel1.Controls.Add(pb[i]);
}
希望本文所述对大家的C#程序设计有所帮助。
相关推荐
-
picturebox加载图片的三种方法与网站验证码的抓取
第一种:(此方法比较笨) 在页面上隐藏几个需要改变页面上图片的picturebox,比如下面的picFrom 在需要改变图片的方法处先定义: System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1)); 然后就可以改变了(比如picTo的图片要改变成picFrom的图片) this.picTo.Image = ((System.Drawing.Image)(res
-
Winform实现将网页生成图片的方法
通常浏览器都有将网页生成图片的功能,本文实例讲述了Winform实现将网页生成图片的方法.分享给大家供大家参考.具体方法如下: 工具截图如下: 生成后的图片如下: 手动填写网站地址,可选择图片类型和保持图片地址,来生成页面的图片,当图片路径未选择时则保存桌面: 具体代码如下: 将html生成图片的类 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usi
-
Winform下实现图片切换特效的方法
本文实例讲述了Winform下实现图片切换特效的方法,是应用程序开发中非常实用的一个功能.分享给大家供大家参考之用.具体方法如下: 本实例源自网络,功能较为齐全.丰富!主要功能代码如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Drawin
-
winform 中显示异步下载的图片
private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { ////利用 WebClient 来下载图片 using (WebClient wc = new WebClient()) { ////WebClient 下载完毕的响应事件绑定 wc.DownloadDataCompleted += new DownloadDataCompletedEventHandler(wc_Dow
-
WinForm中实现picturebox自适应图片大小的方法
本文实例讲述了WinForm中实现picturebox自适应图片大小的方法.分享给大家供大家参考,具体如下: picturebox控件共有两种载入图片方式,分别为: pictureBox1.BackgroundImage = Image,pictureBox1.load(url) 为使加载的图片自使用控件尺寸,可以分别对pictureBox控件设置BackGroundImageLayout=Stretch,SizeMode=StretchImagewinform中picturebox自适应图片大
-
C#给picturebox控件加图片选中状态的2个方法
方法一: 简单的方法就是改变picturebox 控件的borderstyle样式 currentSelectPicBox.BorderStyle = BorderStyle.Fixed3D; currentSelectPicBox.Refresh();//强制控件重新绘制 方法二 在picturebox控件加一个矩形框 但是这种方法在程序中反应比较慢. 添加矩形框的方法: Graphics pictureborder = currentSelect
-
C#图片截取压缩(百分比压缩/大小压缩)实现代码
前端时间朋友要传一些图片给我,全是大图,考虑到网速的限制,让他处理下图片大小再给我,这厮居然不知道用什么工具. 为了娱乐写了个截取图片和压缩图片你的小工具 1.按照百分比截图 复制代码 代码如下: View Code /// <summary> /// 按照比例缩小图片 /// </summary> /// <param name="srcImage">要缩小的图片</param> /// <param name="per
-
Winform在DataGridView中显示图片
首先,要添加图片列,绑定数据的时候会触发CellFormatting事件,在事件中取出图片路径,读取图片赋值给当前单元格. private void dataGridview1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (dataGridview1.Columns[e.ColumnIndex].Name.Equals("Image")) { string path = e.Valu
-
c# 给button添加不规则的图片以及用pictureBox替代button响应点击事件的方法
1.Flat button 用这个方法,前提是要把button的type设置为Flat 复制代码 代码如下: button1.TabStop = false;button1.FlatAppearance.BorderSize = 0;button1.FlatAppearance.BorderColor = Color.FromArgb(0, 255, 255, 255); //设置边框的颜色Transparentbutton1.FlatAppearance.MouseOverBackColor
-
Winform让DataGridView左侧显示图片
效果图片 重写DataGridView的OnRowPostPaint方法或者直接在DataGridView的RowPostPaint事件里写,如下(重写DataGridView的OnRowPostPaint方法) using System; using System.Text; using System.Windows.Forms; using System.Drawing; namespace Test { class DataGridViewEx : DataGridView { Solid
随机推荐
- ColdFusion与FLASH通信轻松入门教程
- SWT(JFace)体验之图片的动态渐变效果
- 分享给Python新手们的几道简单练习题
- asp.net 保存、修改没有 runat=server控件的控件值的一个解决方案
- asp.net request.PathInfo实现的url重写
- ajax+php控制所有后台函数调用
- SSO单点登录的PHP实现方法(Laravel框架)
- 原生JavaScript实现合并多个数组示例
- 使用javascript创建快捷方式的简单实例
- javascript中length属性的探索
- JSP 页面中使用FCKeditor控件(js用法)
- js和jquery设置disabled属性为true使按钮失效
- jquery 问答知识整理
- 个性化blog的方法集锦
- C#实现保存文件时重名自动生成新文件的方法
- XAMPP安装与使用方法详细解析
- 浅谈Linux的编码及编码转换方法
- postman+json+springmvc测试批量添加实例
- nginx常见问题整理和解决办法
- iOS实现新年抽奖转盘效果的思路
