找了好长时间没找到,后来索性自己写了一个:

首先,在往listview加载数据的事件里添加progressbar:

            foreach (string d in arr)
{
int index = lv.Items.Count + ;
item = new ListViewItem(new string[] { index.ToString(), d, "", "", "", "" });
lv.Items.Add(item); float progress = ; Rectangle SizeR = default(Rectangle);
System.Windows.Forms.ProgressBar ProgBar = new System.Windows.Forms.ProgressBar();
SizeR = item.SubItems[].Bounds;
SizeR.Width = lv.Columns[].Width;
ProgBar.Parent = lv;
ProgBar.SetBounds(SizeR.X, SizeR.Y, SizeR.Width, SizeR.Height);
ProgBar.Value = (int)progress;
ProgBar.Visible = true;
//取一个唯一的名字,以后好找
ProgBar.Name = d + "progressbar";
}

然后在需要修改progressbar的值的地方设置它的值:

//循环listview上的所有控件,按名字找到progressbar
foreach (Control item in lv.Controls)
{
if (item.Name == d.Name + "progressbar")
{
ProgressBar bar = (ProgressBar)item;
bar.Value = (int)((d.Progress) * );
}
}

其实我们只是把progressbar根据长宽高固定在了listview指定的格子里,如果我们拖动listview中的列,格子的位置会发生改变,这时候需要修改对应proressbar的位置,我们需要添加ColumnWidthChanging事件,在拖动column的时候,progressbar会随着改变位置:

        private void lvt_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e)
{ Rectangle SizeR = default(Rectangle); int width = e.NewWidth; foreach (Control item in lv.Controls)
{
//根据名字找到所有的progressbar
if (item.Name.IndexOf("progressbar") >= )
{
ProgressBar bar = (ProgressBar)item; //Rectangle size=bar.Bounds;
SizeR=bar.Bounds;
//lv.Columns[2]是放置progressbar的地方
SizeR.Width=lv.Columns[].Width;
bar.SetBounds(lv.Items[].SubItems[].Bounds.X, SizeR.Y, SizeR.Width, SizeR.Height);
//bar.Width = width;
}
}
}

.NET winform 在listview中添加progressbar的更多相关文章

  1. Android 如何在 ListView 中更新 ProgressBar 进度

    =======================ListView原理============================== Android 的 ListView 的原理打个简单的比喻就是: 演员演 ...

  2. 往另外1个ListView中添加当前选中的项目

      //往另外1个ListView中添加当前选中的项目   function AddSelItems(listview1:TListView;ListView2:TListView):Boolean; ...

  3. winform实现listview中combox

    一.概要 因为要在项目中要在ListView中实现下拉框选择,用DataGrid的话,一个不美观,二个绑定数据麻烦,参考网上一种做法,就是单击ListView时,判断单击的区域,然后将Combox控件 ...

  4. WPF: 在ListView中添加Checkbox列表

    描述:ListView是WPF中动态绑定工具的数据容器,本文实现了一个在ListView中显示的供用户选择的列表项目,并且控制列表中选择的项目数量,即实现单选. XAML中创建ListView,代码如 ...

  5. winfrom如何在listview中添加控件

    private Button btn = new Button(); private void Form1_Load(object sender, EventArgs e) { ListViewIte ...

  6. Delphi - 在ListView中添加一个进度条

    // 相关定义 Type TListData = Record FileName: String; Percent: Integer; End; PListData = ^TListData; // ...

  7. ListView中添加ScrollView只显示一两行的问题

    将ListView改为继承NoScrollListView package com.example.brtz.widget; import android.content.Context; impor ...

  8. Android ListView中添加不同的多种布局

    最近做项目要使用ListView加载不同的布局,由于自己写的代码不能贴出,故找了一篇自认为比较好的blog给分享出来,希望对用到此项技术的同学有点帮助. http://logc.at/2011/10/ ...

  9. 在ListView中添加EditText丢失光标问题解决

    <ListView    android:id="@android:id/list"     android:layout_height="fill_parent& ...

随机推荐

  1. [SQL注入3]from_sqli_to_shell_II

    [SQL注入1]这关学习盲注 ,这篇还有些东西没理透,后面搞明白了再修改. http://www.pentesterlab.com/exercises/from_sqli_to_shell_II/ 准 ...

  2. Android 自定义View(button)

    很多的Android入门程序猿来说对于Android自定义View,可能都是比较恐惧的,但是这又是高手进阶的必经之路,所有准备在自定义View上面花一些功夫,多写一些文章.先总结下自定义View的步骤 ...

  3. buffer busy wait

    什么是buffer busy wait? A session that reads or modifies a buffer in the SGA must first acquire the cac ...

  4. CH Round #55 - Streaming #6 (NOIP模拟赛day2)

    A.九九归一 题目:http://ch.ezoj.tk/contest/CH%20Round%20%2355%20-%20Streaming%20%236%20(NOIP模拟赛day2)/九九归一 题 ...

  5. 带’*’号字符串的匹配

    目标: 判断源字符串中是否含有指定子串,子串可能会有*号通配符. 初步测试没问题.记录下来.后面要是有问题再来纠正. #include <string> using namespace s ...

  6. POJ2104-- K-th Number(主席树静态区间第k大)

    [转载]一篇还算可以的文章,关于可持久化线段树http://finaltheory.info/?p=249 无修改的区间第K大 我们先考虑简化的问题:我们要询问整个区间内的第K大.这样我们对值域建线段 ...

  7. JSP入门:介绍什么是JSP和Servlet(转)

    转自:http://developer.51cto.com/art/200907/134506.htm JSP入门:什么是jsp? JSP(Java Server Pages)是由Sun Micros ...

  8. javascript 缓冲运动demo

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. 1346 - Songs (贪心)

    John Doe is a famous DJ and, therefore, has the problem of optimizing the placement of songs on his ...

  10. ApacheBench~网站性能测试工具

    对于网站性能测试来说,一般我们会使用loadrunner来实现,而它过于庞大,使我们感到有些不爽,而今天介绍的ApacheBench工具,它小而精,使用简单,效果直观,可以说,是比lr更好用的性能测试 ...