我有一个非常长时间运行的任务,在我的程序后台异步运行。
虽然它正在执行此操作,但有各种事件负责更新GUI,使用MethodInvoker
确保这些GUI更新始终在主线程上运行。
但是,只调整ToolStripProgressBar
和ToolStripLabel
被更改,似乎我的表单上的两个ListBox
经常被重新绘制,导致它们闪烁。
知道为什么会这样吗?我没有在我的表单中的任何地方使用Update()
,所以我没有理由知道为什么未失效的控件会闪烁。
我还验证了更新ListBox
的事件没有被误解。
进度步骤的EventHandler
设置为以下函数:
private void UpdateProgress()
{
if (InvokeRequired)
{
Invoke((MethodInvoker) UpdateProgress);
return;
}
_lblProgress.Text = $"{_currentRow}/{_totalRows}";
_pbarProgress.Increment(1);
}
这是相当自我解释的,如果需要Invoked
,那么在更新toolStripStatusLabel
和toolStripProgressBar
之前就会这样做。
整个布局已经生成并由WinForms
设计师处理,但这里是代码:
namespace Stability_Report_Generator
{
partial class MainForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this._tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this._lstMontrose = new System.Windows.Forms.ListBox();
this._lstBLP = new System.Windows.Forms.ListBox();
this._tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this._groupBox1 = new System.Windows.Forms.GroupBox();
this._rdoAllData = new System.Windows.Forms.RadioButton();
this._rdoLastShift = new System.Windows.Forms.RadioButton();
this._rdoLastDay = new System.Windows.Forms.RadioButton();
this._tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this._btnGenerate = new System.Windows.Forms.Button();
this._btnView = new System.Windows.Forms.Button();
this._btnClear = new System.Windows.Forms.Button();
this._label1 = new System.Windows.Forms.Label();
this._label2 = new System.Windows.Forms.Label();
this._statusStrip1 = new System.Windows.Forms.StatusStrip();
this._lblStatus = new System.Windows.Forms.ToolStripStatusLabel();
this._lblProgress = new System.Windows.Forms.ToolStripStatusLabel();
this._pbarProgress = new System.Windows.Forms.ToolStripProgressBar();
this._menuStrip1 = new System.Windows.Forms.MenuStrip();
this._fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._addFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._bLpsoeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._montroseSOEToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._removeFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._bLpOnlyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._montroseOnlyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._preferencesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._viewGraphsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this._tableLayoutPanel1.SuspendLayout();
this._tableLayoutPanel2.SuspendLayout();
this._groupBox1.SuspendLayout();
this._tableLayoutPanel3.SuspendLayout();
this._statusStrip1.SuspendLayout();
this._menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// _tableLayoutPanel1
//
this._tableLayoutPanel1.ColumnCount = 3;
this._tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this._tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334F));
this._tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334F));
this._tableLayoutPanel1.Controls.Add(this._lstMontrose, 0, 1);
this._tableLayoutPanel1.Controls.Add(this._lstBLP, 1, 1);
this._tableLayoutPanel1.Controls.Add(this._tableLayoutPanel2, 2, 1);
this._tableLayoutPanel1.Controls.Add(this._label1, 0, 0);
this._tableLayoutPanel1.Controls.Add(this._label2, 1, 0);
this._tableLayoutPanel1.Controls.Add(this._statusStrip1, 2, 2);
this._tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this._tableLayoutPanel1.Location = new System.Drawing.Point(20, 84);
this._tableLayoutPanel1.Name = "_tableLayoutPanel1";
this._tableLayoutPanel1.RowCount = 3;
this._tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this._tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this._tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this._tableLayoutPanel1.Size = new System.Drawing.Size(1090, 420);
this._tableLayoutPanel1.TabIndex = 0;
//
// _lstMontrose
//
this._lstMontrose.Dock = System.Windows.Forms.DockStyle.Fill;
this._lstMontrose.FormattingEnabled = true;
this._lstMontrose.Location = new System.Drawing.Point(3, 23);
this._lstMontrose.Name = "_lstMontrose";
this._lstMontrose.Size = new System.Drawing.Size(357, 374);
this._lstMontrose.TabIndex = 0;
//
// _lstBLP
//
this._lstBLP.Dock = System.Windows.Forms.DockStyle.Fill;
this._lstBLP.FormattingEnabled = true;
this._lstBLP.Location = new System.Drawing.Point(366, 23);
this._lstBLP.Name = "_lstBLP";
this._lstBLP.Size = new System.Drawing.Size(357, 374);
this._lstBLP.TabIndex = 1;
//
// _tableLayoutPanel2
//
this._tableLayoutPanel2.ColumnCount = 1;
this._tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this._tableLayoutPanel2.Controls.Add(this._groupBox1, 0, 1);
this._tableLayoutPanel2.Controls.Add(this._tableLayoutPanel3, 0, 0);
this._tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this._tableLayoutPanel2.Location = new System.Drawing.Point(729, 23);
this._tableLayoutPanel2.Name = "_tableLayoutPanel2";
this._tableLayoutPanel2.RowCount = 2;
this._tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this._tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this._tableLayoutPanel2.Size = new System.Drawing.Size(358, 374);
this._tableLayoutPanel2.TabIndex = 2;
//
// _groupBox1
//
this._groupBox1.Controls.Add(this._rdoAllData);
this._groupBox1.Controls.Add(this._rdoLastShift);
this._groupBox1.Controls.Add(this._rdoLastDay);
this._groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this._groupBox1.Location = new System.Drawing.Point(3, 190);
this._groupBox1.Name = "_groupBox1";
this._groupBox1.Size = new System.Drawing.Size(352, 181);
this._groupBox1.TabIndex = 0;
this._groupBox1.TabStop = false;
this._groupBox1.Text = "Time Period";
//
// _rdoAllData
//
this._rdoAllData.AutoSize = true;
this._rdoAllData.Location = new System.Drawing.Point(16, 68);
this._rdoAllData.Name = "_rdoAllData";
this._rdoAllData.Size = new System.Drawing.Size(62, 17);
this._rdoAllData.TabIndex = 2;
this._rdoAllData.TabStop = true;
this._rdoAllData.Text = "All Data";
this._rdoAllData.UseVisualStyleBackColor = true;
//
// _rdoLastShift
//
this._rdoLastShift.AutoSize = true;
this._rdoLastShift.Location = new System.Drawing.Point(16, 44);
this._rdoLastShift.Name = "_rdoLastShift";
this._rdoLastShift.Size = new System.Drawing.Size(69, 17);
this._rdoLastShift.TabIndex = 1;
this._rdoLastShift.TabStop = true;
this._rdoLastShift.Text = "Last Shift";
this._rdoLastShift.UseVisualStyleBackColor = true;
//
// _rdoLastDay
//
this._rdoLastDay.AutoSize = true;
this._rdoLastDay.Location = new System.Drawing.Point(16, 20);
this._rdoLastDay.Name = "_rdoLastDay";
this._rdoLastDay.Size = new System.Drawing.Size(67, 17);
this._rdoLastDay.TabIndex = 0;
this._rdoLastDay.TabStop = true;
this._rdoLastDay.Text = "Last Day";
this._rdoLastDay.UseVisualStyleBackColor = true;
//
// _tableLayoutPanel3
//
this._tableLayoutPanel3.ColumnCount = 1;
this._tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this._tableLayoutPanel3.Controls.Add(this._btnGenerate, 0, 0);
this._tableLayoutPanel3.Controls.Add(this._btnView, 0, 1);
this._tableLayoutPanel3.Controls.Add(this._btnClear, 0, 2);
this._tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
this._tableLayoutPanel3.Location = new System.Drawing.Point(3, 3);
this._tableLayoutPanel3.Name = "_tableLayoutPanel3";
this._tableLayoutPanel3.RowCount = 3;
this._tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this._tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this._tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this._tableLayoutPanel3.Size = new System.Drawing.Size(352, 181);
this._tableLayoutPanel3.TabIndex = 1;
//
// _btnGenerate
//
this._btnGenerate.Dock = System.Windows.Forms.DockStyle.Fill;
this._btnGenerate.Enabled = false;
this._btnGenerate.Location = new System.Drawing.Point(3, 3);
this._btnGenerate.Name = "_btnGenerate";
this._btnGenerate.Size = new System.Drawing.Size(346, 54);
this._btnGenerate.TabIndex = 0;
this._btnGenerate.Text = "Generate Report";
this._btnGenerate.UseVisualStyleBackColor = true;
this._btnGenerate.Click += new System.EventHandler(this.btnGenerate_Click);
//
// _btnView
//
this._btnView.Dock = System.Windows.Forms.DockStyle.Fill;
this._btnView.Enabled = false;
this._btnView.Location = new System.Drawing.Point(3, 63);
this._btnView.Name = "_btnView";
this._btnView.Size = new System.Drawing.Size(346, 54);
this._btnView.TabIndex = 1;
this._btnView.Text = "View Details";
this._btnView.UseVisualStyleBackColor = true;
//
// _btnClear
//
this._btnClear.Dock = System.Windows.Forms.DockStyle.Fill;
this._btnClear.Enabled = false;
this._btnClear.Location = new System.Drawing.Point(3, 123);
this._btnClear.Name = "_btnClear";
this._btnClear.Size = new System.Drawing.Size(346, 55);
this._btnClear.TabIndex = 2;
this._btnClear.Text = "Reset";
this._btnClear.UseVisualStyleBackColor = true;
//
// _label1
//
this._label1.AutoSize = true;
this._label1.Dock = System.Windows.Forms.DockStyle.Fill;
this._label1.Location = new System.Drawing.Point(3, 0);
this._label1.Name = "_label1";
this._label1.Size = new System.Drawing.Size(357, 20);
this._label1.TabIndex = 3;
this._label1.Text = "Montrose SOE Files";
//
// _label2
//
this._label2.AutoSize = true;
this._label2.Dock = System.Windows.Forms.DockStyle.Fill;
this._label2.Location = new System.Drawing.Point(366, 0);
this._label2.Name = "_label2";
this._label2.Size = new System.Drawing.Size(357, 20);
this._label2.TabIndex = 4;
this._label2.Text = "BLP SOE Files";
//
// _statusStrip1
//
this._statusStrip1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this._statusStrip1.BackColor = System.Drawing.Color.White;
this._statusStrip1.Dock = System.Windows.Forms.DockStyle.None;
this._statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this._lblStatus,
this._lblProgress,
this._pbarProgress});
this._statusStrip1.Location = new System.Drawing.Point(936, 400);
this._statusStrip1.Name = "_statusStrip1";
this._statusStrip1.RightToLeft = System.Windows.Forms.RightToLeft.No;
this._statusStrip1.Size = new System.Drawing.Size(154, 20);
this._statusStrip1.SizingGrip = false;
this._statusStrip1.Stretch = false;
this._statusStrip1.TabIndex = 5;
this._statusStrip1.Text = "statusStrip1";
//
// _lblStatus
//
this._lblStatus.Name = "_lblStatus";
this._lblStatus.Size = new System.Drawing.Size(35, 15);
this._lblStatus.Text = "Idle...";
//
// _lblProgress
//
this._lblProgress.Name = "_lblProgress";
this._lblProgress.Size = new System.Drawing.Size(0, 15);
//
// _pbarProgress
//
this._pbarProgress.Name = "_pbarProgress";
this._pbarProgress.Size = new System.Drawing.Size(100, 14);
//
// _menuStrip1
//
this._menuStrip1.BackColor = System.Drawing.Color.White;
this._menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this._fileToolStripMenuItem,
this._editToolStripMenuItem,
this._toolsToolStripMenuItem});
this._menuStrip1.Location = new System.Drawing.Point(20, 60);
this._menuStrip1.Name = "_menuStrip1";
this._menuStrip1.Size = new System.Drawing.Size(1090, 24);
this._menuStrip1.TabIndex = 1;
this._menuStrip1.Text = "menuStrip1";
//
// _fileToolStripMenuItem
//
this._fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this._addFilesToolStripMenuItem});
this._fileToolStripMenuItem.Name = "_fileToolStripMenuItem";
this._fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this._fileToolStripMenuItem.Text = "File";
//
// _addFilesToolStripMenuItem
//
this._addFilesToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this._bLpsoeToolStripMenuItem,
this._montroseSOEToolStripMenuItem});
this._addFilesToolStripMenuItem.Name = "_addFilesToolStripMenuItem";
this._addFilesToolStripMenuItem.Size = new System.Drawing.Size(122, 22);
this._addFilesToolStripMenuItem.Text = "Add Files";
//
// _bLpsoeToolStripMenuItem
//
this._bLpsoeToolStripMenuItem.Name = "_bLpsoeToolStripMenuItem";
this._bLpsoeToolStripMenuItem.Size = new System.Drawing.Size(149, 22);
this._bLpsoeToolStripMenuItem.Text = "BLP SOE";
//
// _montroseSOEToolStripMenuItem
//
this._montroseSOEToolStripMenuItem.Name = "_montroseSOEToolStripMenuItem";
this._montroseSOEToolStripMenuItem.Size = new System.Drawing.Size(149, 22);
this._montroseSOEToolStripMenuItem.Text = "Montrose SOE";
//
// _editToolStripMenuItem
//
this._editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this._removeFilesToolStripMenuItem,
this._preferencesToolStripMenuItem});
this._editToolStripMenuItem.Name = "_editToolStripMenuItem";
this._editToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
this._editToolStripMenuItem.Text = "Edit";
//
// _removeFilesToolStripMenuItem
//
this._removeFilesToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this._bLpOnlyToolStripMenuItem,
this._montroseOnlyToolStripMenuItem});
this._removeFilesToolStripMenuItem.Name = "_removeFilesToolStripMenuItem";
this._removeFilesToolStripMenuItem.Size = new System.Drawing.Size(143, 22);
this._removeFilesToolStripMenuItem.Text = "Remove Files";
//
// _bLpOnlyToolStripMenuItem
//
this._bLpOnlyToolStripMenuItem.Name = "_bLpOnlyToolStripMenuItem";
this._bLpOnlyToolStripMenuItem.Size = new System.Drawing.Size(153, 22);
this._bLpOnlyToolStripMenuItem.Text = "BLP Only";
//
// _montroseOnlyToolStripMenuItem
//
this._montroseOnlyToolStripMenuItem.Name = "_montroseOnlyToolStripMenuItem";
this._montroseOnlyToolStripMenuItem.Size = new System.Drawing.Size(153, 22);
this._montroseOnlyToolStripMenuItem.Text = "Montrose Only";
//
// _preferencesToolStripMenuItem
//
this._preferencesToolStripMenuItem.Name = "_preferencesToolStripMenuItem";
this._preferencesToolStripMenuItem.Size = new System.Drawing.Size(143, 22);
this._preferencesToolStripMenuItem.Text = "Preferences";
//
// _toolsToolStripMenuItem
//
this._toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this._viewGraphsToolStripMenuItem});
this._toolsToolStripMenuItem.Name = "_toolsToolStripMenuItem";
this._toolsToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
this._toolsToolStripMenuItem.Text = "Tools";
//
// _viewGraphsToolStripMenuItem
//
this._viewGraphsToolStripMenuItem.Name = "_viewGraphsToolStripMenuItem";
this._viewGraphsToolStripMenuItem.Size = new System.Drawing.Size(139, 22);
this._viewGraphsToolStripMenuItem.Text = "View Graphs";
//
// MainForm
//
this.AllowDrop = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1130, 524);
this.Controls.Add(this._tableLayoutPanel1);
this.Controls.Add(this._menuStrip1);
this.MainMenuStrip = this._menuStrip1;
this.Name = "MainForm";
this.Text = "Stability Report Generator";
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.MainForm_DragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.MainForm_DragEnter);
this._tableLayoutPanel1.ResumeLayout(false);
this._tableLayoutPanel1.PerformLayout();
this._tableLayoutPanel2.ResumeLayout(false);
this._groupBox1.ResumeLayout(false);
this._groupBox1.PerformLayout();
this._tableLayoutPanel3.ResumeLayout(false);
this._statusStrip1.ResumeLayout(false);
this._statusStrip1.PerformLayout();
this._menuStrip1.ResumeLayout(false);
this._menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TableLayoutPanel _tableLayoutPanel1;
private System.Windows.Forms.TableLayoutPanel _tableLayoutPanel2;
private System.Windows.Forms.GroupBox _groupBox1;
private System.Windows.Forms.RadioButton _rdoAllData;
private System.Windows.Forms.RadioButton _rdoLastShift;
private System.Windows.Forms.RadioButton _rdoLastDay;
private System.Windows.Forms.TableLayoutPanel _tableLayoutPanel3;
private System.Windows.Forms.Button _btnGenerate;
private System.Windows.Forms.Button _btnView;
private System.Windows.Forms.Button _btnClear;
private System.Windows.Forms.MenuStrip _menuStrip1;
private System.Windows.Forms.ToolStripMenuItem _fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem _addFilesToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem _bLpsoeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem _montroseSOEToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem _editToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem _removeFilesToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem _bLpOnlyToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem _montroseOnlyToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem _preferencesToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem _toolsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem _viewGraphsToolStripMenuItem;
private System.Windows.Forms.ListBox _lstMontrose;
private System.Windows.Forms.ListBox _lstBLP;
private System.Windows.Forms.Label _label1;
private System.Windows.Forms.Label _label2;
private System.Windows.Forms.StatusStrip _statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel _lblStatus;
private System.Windows.Forms.ToolStripProgressBar _pbarProgress;
private System.Windows.Forms.ToolStripStatusLabel _lblProgress;
}
}
答案 0 :(得分:1)
您看到闪烁的原因是默认情况下ListBox.IntegralHeight
为true
的副作用,触发调整大小算法,该算法根据内容更改控件的大小,它是显然会造成副作用。
当您每100毫秒更新一次进度条时,会出现问题。更快,然后立即导致闪烁,也许它与进度条控件的渲染循环的内部实现有关,它正在调用SendMessage(NativeMethods.PBM_SETPOS, value, 0)
或窗口消息循环本身的内部和渲染方式在幕后实施,很难说。
您可以选择通过将进度条增量与_currentRow
增量分开来减慢进度条的更新速度,例如通过将进度条增量放在每100毫秒甚至更慢的其他计时器滴答处理程序中。
或者将IntegralHeight
属性设置为false
,请参阅下文。
this._lstMontrose.IntegralHeight = false;
this._lstBLP.IntegralHeight = false;
希望它能解决你的问题!
答案 1 :(得分:0)
创建一个新的自定义控件,继承标准列表框,然后在构造函数中打开DoubleBuffered:
public class CustomListBox : ListBox
{
public CustomListBox() : base()
{
base.DoubleBuffered = true;
}
}
将表单上两个Listbox的类型更改为新的ListBox类。
这可能有助于解决闪烁的重绘问题。
答案 2 :(得分:-1)
试试这个:
private void UpdateProgress()
{
_lblProgress.BeginInvoke((Action) (() =>
{
_lblProgress.Text = string.Format("{0}/{1}", _currentRow, _totalRows)
_pbarProgress.Increment(1);
});
}