试了2种办法,但都无效?需求:判断图片控件的尺寸,如超过指定大小,则调整
1、
System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
img.ImageUrl=slArticle["article_Pics"].ToString();
if (img.Width.Value>60)
{
img.Width=Unit.Pixel(60);
}
this.Panel1.Controls.Add(img);
2、
this.Image1.Visible=true;
this.Image1.ImageUrl=slArticle["article_Pics"].ToString();
if (this.Image1.Width.Value>60)
{
this.Image1.Width=Unit.Pixel(60);
}
this.Response.Write(img.Width.Value);
1、
System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
img.ImageUrl=slArticle["article_Pics"].ToString();
if (img.Width.Value>60)
{
img.Width=Unit.Pixel(60);
}
this.Panel1.Controls.Add(img);
2、
this.Image1.Visible=true;
this.Image1.ImageUrl=slArticle["article_Pics"].ToString();
if (this.Image1.Width.Value>60)
{
this.Image1.Width=Unit.Pixel(60);
}
this.Response.Write(img.Width.Value);
解决方案 »
- C#调用DOS命令,实现拨号功能
- winform进度条的问题
- 如何把byte类型转换为sting或char ???
- 枚举成员如何写XML注释?
- 修改ComboBox控件的哪个属性可以使其长短随着窗口大小的变化而变化??
- 急!讨论送分,请教C#的WINFORM高手,如何实现流程导航系统?
- 关于Insert into的问题
- 请教大家一下静态构造函数是什么时候被调用的?非常感谢!!
- 初学c#,向各位高人求教几个问题,解决问题了再给分重谢。
- [請教]一個關於ClickOnce遠程發佈的問題
- 监听线程显示图片问题!高手一定来看看!版主也来啊!
- 在往DataGrid item的cell内add控件时,不是新增而是替换,是何原因?
using(Image img = Image.FormFile(filePath))
{
if(img.Width >60)
{
this.Image1.Width=Unit.Pixel(60);
}
}
// 使用缩略图需要的回调函数。空,不做任何动作
public static bool ThumbnailCallback()
{return false;}
调用:
if(System.IO.File.Exists(ImgPath))
{
Image.GetThumbnailImageAbort myCallback =new Image.GetThumbnailImageAbort(ThumbnailCallback);
Image simg=Image.FromFile(si.ImgPath).GetThumbnailImage( PictureBox1.Width, PictureBox1.Height, myCallback, IntPtr.Zero);
PictureBox1.Image=simg;