我有一个带gif的图片框(gif正常工作)。编写我的程序是为了打开位于该国另一边的驱动器上的文档文件,因此需要一些时间。
我在程序启动连接过程时设置了picturebox.visible = true
,但gif在此过程中没有动画;但只有在闲着的时候。
Google搜索引导我进行后台工作人员控制,但在我发现的所有示例中,我找不到一个可以:
让gif在后台工作器中永久运行(我假设这不会消耗太多内存,因为它只是一个gif)
或
在应用程序连接时让gif动画
有人可以帮忙吗?
从评论中,我假设整个事情都需要在backgroundworker.dowork中,但我只是不断收到错误,因为我在这里更改控件。
Private Sub btnLoad_Click(sender as Object,e As EventArgs)处理btnLoad.Click
'Displaying "Loading"
picLoading.Visible = True
tblMain.Visible = False
'If the application has loaded at least one sheet
If FirstLoad = 2 Then
worksheet.Cells(1, 31).Value = ""
workbook.Save()
workbook.Close(False)
End If
Filter = cmbFilter.Text
'Go to page 1
CurrentPage = 0
workbook = APP.Workbooks.Open(Path & "\" & Filter & ".xlsx")
worksheet = workbook.Worksheets("Sheet1")
If Convert.ToString(worksheet.Cells(1, 31).Value) <> "" Then
MsgBox("The sheet for " & Filter & " is currently being used by " & Convert.ToString(worksheet.Cells(1, 31).Value) & ".")
workbook.Close(False)
Else
FirstLoad = 2 'Indicate that the application has loaded at least one sheet
worksheet.Cells(1, 31).Value = User
'Make all textboxes and comboboxes visible = false
txtSearch.Visible = False : btnSort.Visible = False : btnSortUrgency.Visible = False : btnSave.Visible = False : btnPrevious.Visible = False : btnNext.Visible = False
Label1.Visible = False
Label2.Visible = False
'Count entries and calculate how many pages there are
Entries = worksheet.Range("B1048576").End(Excel.XlDirection.xlUp).Row 'Count how many entries there are (the first row always counts as an entry)
TotalPages = Math.Ceiling(Entries / 8) - 1 'Calculate how many pages there are
If TotalPages = (Entries / 8) - 1 Then
TotalPages = TotalPages + 1
End If
'Determine how many entries are on the last page
LastEntries = Entries
While LastEntries > 8 'Keep subtracting by 8 to determine how many entries are going to be on the last page
LastEntries = LastEntries - 8
End While
'Add categories for the Urgency comboboxes
Me.cmbUrgency1.DrawMode = DrawMode.OwnerDrawFixed
Me. cmbUrgency1.DropDownStyle = ComboBoxStyle.DropDownList
Me. cmbUrgency1.ItemHeight = 15
Me. cmbUrgency1.BeginUpdate()
cmbUrgency1.Items.Clear()
Me. cmbUrgency1.Items.Add("1")
Me. cmbUrgency1.Items.Add("2")
Me. cmbUrgency1.Items.Add("3")
Me. cmbUrgency1.Items.Add("4")
cmbUrgency1.EndUpdate()
Me. cmbUrgency2.DrawMode = DrawMode.OwnerDrawFixed
Me. cmbUrgency2.DropDownStyle = ComboBoxStyle.DropDownList
Me. cmbUrgency2.ItemHeight = 15
Me. cmbUrgency2.BeginUpdate()
cmbUrgency2.Items.Clear()
Me. cmbUrgency2.Items.Add("1")
Me. cmbUrgency2.Items.Add("2")
Me. cmbUrgency2.Items.Add("3")
Me. cmbUrgency2.Items.Add("4")
cmbUrgency2.EndUpdate()
Me. cmbUrgency3.DrawMode = DrawMode.OwnerDrawFixed
Me. cmbUrgency3.DropDownStyle = ComboBoxStyle.DropDownList
Me. cmbUrgency3.ItemHeight = 15
Me. cmbUrgency3.BeginUpdate()
cmbUrgency3.Items.Clear()
Me. cmbUrgency3.Items.Add("1")
Me. cmbUrgency3.Items.Add("2")
Me. cmbUrgency3.Items.Add("3")
Me. cmbUrgency3.Items.Add("4")
Urgency3.EndUpdate()
Me.Urgency4.DrawMode = DrawMode.OwnerDrawFixed
Me.Urgency4.DropDownStyle = ComboBoxStyle.DropDownList
Me.Urgency4.ItemHeight = 15
Me.Urgency4.BeginUpdate()
Urgency4.Items.Clear()
Me.Urgency4.Items.Add("1")
Me.Urgency4.Items.Add("2")
Me.Urgency4.Items.Add("3")
Me.Urgency4.Items.Add("4")
Urgency4.EndUpdate()
Dim DataCollection As New AutoCompleteStringCollection()
txtBlank.AutoCompleteMode = AutoCompleteMode.Suggest
txtBlank.AutoCompleteSource = AutoCompleteSource.CustomSource
AddItems(DataCollection)
txtBlank.AutoCompleteCustomSource = DataCollection
txtBlank2.AutoCompleteMode = AutoCompleteMode.Suggest
txtBlank2.AutoCompleteSource = AutoCompleteSource.CustomSource
AddItems(DataCollection)
txtBlank2.AutoCompleteCustomSource = DataCollection
txtBlank3.AutoCompleteMode = AutoCompleteMode.Suggest
txtBlank3.AutoCompleteSource = AutoCompleteSource.CustomSource
AddItems(DataCollection)
txtBlank3.AutoCompleteCustomSource = DataCollection
txtBlank3.AutoCompleteMode = AutoCompleteMode.Suggest
txtBlank3.AutoCompleteSource = AutoCompleteSource.CustomSource
AddItems(DataCollection)
txtBlank3.AutoCompleteCustomSource = DataCollection
workbook.Save()
Call DisplayInfo()
End If
End Sub