 |
|
ขอคำแนะนำ เรื่องการแสดงข้อมูล การโหลดข้อมูลหน่อยครับ |
|
 |
|
|
 |
 |
|
ลองใช้ตัวนี้ดูนะครับ
Code (C#)
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());
}
/// <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;
}
อาจจะ Error ตรง
Code (C#)
this.pictureBox1.Image = global::DATA_CSharp.Properties.Resources.wait9;
ค้นหารูปมาใส่เอานะครับ(อยากได้แบบไหนก็ว่ากันไป)
วิธีใช้ ประมาณนี้ครับ
Code (C#)
using (Class.frmWaitFormDialog f = new DATA_CSharp.Class.frmWaitFormDialog(new Action(() =>
{
var bw = sender as BackgroundWorker;
var i = 0;
while (i < 100 && !bw.CancellationPending)
{
bw.ReportProgress(i);
Thread.Sleep(100);
i++;
}
}));
})))
{
f.ShowDialog(this); //ตัว this จะมีหรือไม่มีก็ขึ้นกับความสะดวกของเราเอง ครับ
}
|
 |
 |
 |
 |
Date :
2018-05-22 15:44:20 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|