All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
ASP.Net留言本:用ASP.Net和Access编写留言本_[Asp.Net教程]
去除正文中的html标记,但是又想保留其中的<br>_[Asp.Net教程]
精通数据库系列之入门-技巧篇3_mssql学习_编程技术
什么是动态链接库
实例讲解PHP中实现代码重用的两个函数_php资料_编程技术
关于.NET中MD5加密与ASP中MD5加密值不同的解决办法_[Asp.Net教程]
ASP.NET,MVC,框架_[Asp.Net教程]
新瓶旧酒ASP.NET,AJAX(7),-,客户端脚本编程(Sys命名空间下的类)_[Asp.Net教程]
VC#2005快速入门之复合赋值操作符_[Asp.Net教程]
delphi模拟按下键盘上的某个键
Reading number is top 10 pictures
贩卖儿童者必须判死刑
男人巳快沦落成动物了
Terrorist smile the largest human history an explosion1
10 powerless things in life
清纯性感的美眉1
China's programmers are live what kind, had a look at will know that
全球十大灵异酒店
In the world the most mysterious 21 place landscape3
传奇套装
Group of female porn in 《westwards》, uninhibited woman threatened to not the bottom line
Download software ranking
asp.netWeb服务器高级编程
都市狐狸姑娘传
Boxer vs Yellow3
Unix video tutorial4
Sora aoi - one of more PK
尖东毒玫瑰A
Sora aoi's film--cangkong_Blue.Sky
Unix video tutorial6
Tram sex maniac 2 (H) rar bag18
Unix video tutorial10
delv published in(发表于) 2014/1/23 3:11:39 Edit(编辑)
ASP.NET实现投票结果的图片进度条显示代码_[Asp.Net教程]

ASP.NET实现投票结果的图片进度条显示代码_[Asp.Net教程]

ASP.NET实现投票结果的图片进度条显示代码_[Asp.Net教程]

  一个投票功能模块少不了查看投票结果,用进度条显示各个投票结果可以起到一目了然的效果。以下是我的方法,请大家不吝赐教:


  1:做一张图片用于做进度条,只需要很小的一个图片就可以了,如高20px,宽1px。


  2:在要显示进度条的单元格中插入image控件,其imageUrl设置为已做好的图片的位置。


  3:用一个dataReader对象dr保存取出的各项票数,用一个int 型变量sum保存取出的总票数,各项分别再定义一个double型变量用来保存单项票数除以(/)总票数的结果(小数),再定义一个int型的变量来保存最终要显示的进度条的长度(用前面那个double型变量*用来显示进度条的单元格的长度,然后强制转换为int型),将长度赋值给图片的width 属性即可,以下为我的代码片段,显示四个进度条:


SqlCommand cmd=new SqlCommand("select * from TvoteNum order by Vid",con);//查出各项的投票结果的sql语句
SqlDataReader dr=cmd.ExecuteReader();
......


SqlCommand cmd1=new SqlCommand("select sum(Vnum) from TvoteNum",con1);//查出总票数的sql语句
int sum=Convert.ToInt32(cmd1.ExecuteScalar());
......

dr.Read();//读datareader对象的第一条记录
this.Label1.Text=dr.GetInt32(1).ToString();//第一项的票数
double w1=(Convert.ToDouble(this.Label1.Text)/sum);//此项票数占总票数的百分比
int wid1=(int)(w1*310);//转化为具体象素,310为要用来显示进度条的单元格长度
this.Image1.Width=wid1;//赋值给图片的宽度
dr.Read();//读第二条记录
this.Label2.Text=dr.GetInt32(1).ToString();
double w2=(Convert.ToDouble(this.Label2.Text)/sum);
int wid2=(int)(w2*310);
this.Image2.Width=wid2;

dr.Read();//读第三条记录
this.Label3.Text=dr.GetInt32(1).ToString();
double w3=(Convert.ToDouble(this.Label3.Text)/sum);
int wid3=(int)(w3*310);
this.Image3.Width=wid3;

dr.Read();//读第四条记录
this.Label4.Text=dr.GetInt32(1).ToString();
double w4=(Convert.ToDouble(this.Label4.Text)/sum);
int wid4=(int)(w4*310);
this.Image4.Width=wid4;

来源:网络







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.