对的,这是可能的:
ImageList并添加一个BitmapListView并将ImageList上面创建的作为附件附加SmallImageListListView样式DetailsListViewItem为每列添加具有适当字符串的后续s,并在第一步中创建适当的ImageIndex引用Bitmap
//...
{
foreach (/*item to add to list*/)
{
Bitmap progressBarBitmap = new Bitmap(
this.imageList.ImageSize.Width,
this.imageList.ImageSize.Height);
this.imageList.Images.Add(progressBarBitmap);
ProgressBar progressBar = new ProgressBar();
progressBar.MinimumSize = this.imageList.ImageSize;
progressBar.MaximumSize = this.imageList.ImageSize;
progressBar.Size = this.imageList.ImageSize;
// probably create also some BackgroundWorker here with information about
// this particular progressBar
ListViewItem lvi = new ListViewItem(
new[] { "column1", ... },
this.listView.Items.Count);
lvi.UseItemStyleForSubItems = true;
this.listView.Items.Add(lvi);
lvi.Tag = /* some convenient info class to refer back to related objects */
}
//...
}
Run Code Online (Sandbox Code Playgroud)
ProgressBar:
int previousProgress = progressBar.Value;
progressBar.Value = ...
if (progressBar.Value != previousProgress)
{
progressBar.DrawToBitmap(progressBarBitmap, bounds);
progressBarImageList.Images[index] = progressBarBitmap;
}
Run Code Online (Sandbox Code Playgroud)
progressBarBitmap适当的位置(index)的图像在哪里progressBarImageList适当progressBar(当然每个ListViewItem都有它自己ProgressBar分配).
关键是将同一图像再次分配到同一个地方ImageList- 这会导致重新绘制,如果没有这个,它就无法工作.
优点:快速(不必编写自己的UserControl),便宜(有很多调查要找出这个,但最终写的代码不多),并且有效
缺点:当有大量物品时,我注意到有些闪烁.此外,Mono还有一些令人耳目一新的问题.
代码示例应用程序:https://github.com/bartoszkp/dotrl(BSD许可证) - 特别参见BatchExperimentWindow类:https://github.com/bartoszkp/dotrl/blob/master/Application/BatchExperimentWindow.cs
| 归档时间: |
|
| 查看次数: |
5417 次 |
| 最近记录: |