打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
C# PictureBox 使用心得

Synchronously loading image

PictureBox pbx = new PictureBox();
pbx.Image = Image.FromFile(filename);
or
PictureBox pbx = new PictureBox();
pbx.Load(filename); // filename could be the url file://filename
Asynchronously loading image
private void btnOpen_Click(object sender, EventArgs e)
{
PictureBox pbxPic= new PictureBox();
pbxPic.WaitOnLoad = false;
pbxPic.LoadAsync(url or filename);
}
private void pbxPic_LoadCompleted(object sender, AsyncCompletedEventArgs e)
{
this.stsStatus.SuspendLayout();

this.stsStatus.Items['tsslblLocation'].Text = pbxPic.ImageLocation;

this.stsStatus.ResumeLayout(false);
this.stsStatus.PerformLayout();
}
private void pbxPic_LoadProgressChanged(object sender, ProgressChangedEventArgs e)
{
ToolStripProgressBar pgb = this.stsStatus.Items['tsspgbLoading'] as ToolStripProgressBar;
if (pgb != null)
{
pgb.Value = e.ProgressPercentage;
}
}

Show Image in picturebox

The simple one is use PictureBoxSizeMode.Zoom enum to make the image fit to the picturebox in radio

If you want to show the scroll bar, you should add picturebox into a panel. And then set panel’ autoscroll as true and set picturebox’s sizemode as PictureBoxSizeMode as Auto.

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
在C#中 从一个picturebox中 按住鼠标左键不放 画一块区域后,另外一个picturebox(在一个winform 窗体上有两个picturebox )上马上把对应的截取图像显
C#中pictureBox上如何设置label透明
C# PictureBox控件显示本地图片和显示网上图片
C#图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果)
数字图像处理 C# 程序代码实例
c#截图工具
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服