using Iterateds.Properties;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace Iterateds {
public partial class Main : Form {
public static readonly int Max = 10;
public static List<string> Files = new List<string>();
public static int CountFiles = 0,
Threaded = 0,
Counters = 0;
public Main() {
string File;
StringReader strReader = new StringReader(Resources.files.Trim());
while (null != (File = strReader.ReadLine())) {
Files.Add(File);
}
CountFiles = Files.Count;
InitializeComponent();
}
public void Iterated() {
if (0 >= Files.Count) {
return;
}
string selectPath = this.selectPath?.Text;
if (string.IsNullOrEmpty(selectPath.Trim())) {
return;
}
int Counter = 0;
foreach (string file in Files) {
if (Main.Counters >= Counter) {
Counter;
continue;
}
if (Max > Threaded) {
string filed = file.Trim();
if (string.IsNullOrEmpty(filed)) {
continue;
}
// -----------------------------------------------
// -----------------------------------------------
// -----------------------------------------------
//////////////////////////
// THE PROBLEM IS HERE: //
//////////////////////////
ListViewItem item = new ListViewItem(filed);
ProgressBar pb = new ProgressBar {
Maximum = 100
};
this.Logs.Items.Add(item);
Rectangle r = item.Bounds;
pb.SetBounds(r.X, r.Y, r.Width, r.Height);
this.Logs.Controls.Add(pb);
///////////////////////////////
// ^^ THE PROBLEM IS HERE ^^ //
///////////////////////////////
// -----------------------------------------------
// -----------------------------------------------
// -----------------------------------------------
// here is the load manager, after we reach "Threaded" it starts "Iterated" again to take another "Max" or the remainder if less.
Threaded;
}
}
}
}
}
問題是,當第一次添加時,一切都很好,但我意識到它們粘在螢屏上,在下一次迭代之后,它們不再出現進度條,或者在一個地方的一堆下面的某個地方,好像它是有 1,檔案本身的路徑會根據需要顯示。
問題可能是由于pb.SetBounds,既然ListView有一個滾動條,滾動和一切都崩潰了,也許有人會告訴你如何解決這樣的問題?
我需要左邊的檔案地址,右邊的進度條,其他什么都不需要。
每次的功能應該不超過Max.
也就是說,一次只能Max處理或更少。
uj5u.com熱心網友回復:
ListView沒有, through也可以解決TableLayoutPanel。
this.tableLayoutPanel1.RowCount = 1;
Label txt = new Label {
Text = filed
};
txt.AutoSize = true;
ProgressBar pb = new ProgressBar {
Maximum = 100
};
pb.Height = 10;
this.tableLayoutPanel1.Controls.Add(txt);
this.tableLayoutPanel1.Controls.Add(pb);
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/510010.html
標籤:C#表格
上一篇:僅父滾動條(無子滾動條)
