-
创建一个隐藏的PictureBox:picProcessing
-
设置PictureBox的gif路径
private void BarcodeLogForm_Load(object sender, EventArgs e)
{
this.picProcessing.Image = Image.FromFile(@"pic/loading-small.gif");
}
- 创建Timer对单元格定时重新绘制
#region 创建Timer
Timer timGifAnimation = new System.Windows.Forms.Timer();
timGifAnimation.Enabled = true;
timGifAnimation.Tick += timGifAnimation_Tick;
#endregion
//定时重绘
private void timGifAnimation_Tick(object sender, EventArgs e)
{
if (this.gridBarcode.Rows.Count > 0 && this.currentStep >= 0)
{
this.gridBarcode.Rows[currentStep].Cells["clmBarcodeSend"].Value = this.picProcessing.Image;
this.gridBarcode.InvalidateCell(gridBarcode.Columns.IndexOf(clmBarcodeSend), currentStep);
}
}
- 效果