|
|
|
ดึงข้อมูลเก็บไว้ที่ Datatable ใช้ ProgressBar ยังไงแบบไม่วนลูป |
|
|
|
|
|
|
|
ผมใช้ dialog แบบนี้ครับ
Code (C#)
namespace DATA_CSharp.Class
{
partial class frmWaitFormDialog
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmWaitFormDialog));
this.pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox1.Image = global::DATA_CSharp.Properties.Resources.wait9;
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(423, 201);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// frmWaitFormDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(423, 201);
this.ControlBox = false;
this.Controls.Add(this.pictureBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "frmWaitFormDialog";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "WaitFormDialog";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
}
}
Code (C#)
namespace DATA_CSharp.Class
{
public partial class frmWaitFormDialog : Form
{
public Action Worker { get; set; }
public frmWaitFormDialog(Action worker)
{
InitializeComponent();
if (worker == null) throw new ArgumentNullException();
this.CenterToScreen();
Worker = worker;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Task.Factory.StartNew(Worker).ContinueWith(t => { this.Close(); }, TaskScheduler.FromCurrentSynchronizationContext());
}
}
}
เวลาเรียกใช้งานก็ ประมาณนี้
Code (C#)
using (Class.frmWaitFormDialog f = new DATA_CSharp.Class.frmWaitFormDialog(new Action(RefreshData)))
{
f.ShowDialog(this);
}
RefreshData คือ method ในการ refresh ข้อมูลครับ
|
|
|
|
|
Date :
2018-06-27 08:38:00 |
By :
lamaka.tor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
การทำ ProgressBar แบบ Dialog ทำงานร่วมกับ BackgroundWorker
|
|
|
|
|
Date :
2018-06-27 12:34:43 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2018-06-28 09:41:53 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|