zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    nginx主配置文件详解
    微信网页第三方登录原理
    QQ第三方登陆流程详解
    php垃圾回收机制
    mysql索引
    MySQL性能优化的最佳20+条经验
    MYSQL explain详解
    mysql分区功能详细介绍,以及实例
    MySQL分表、分区
    Redis主从读写分离配置
  • 原文地址:https://www.cnblogs.com/rogerroddick/p/2940315.html
Copyright © 2011-2022 走看看