-2
首先我的代碼:如何更新每個循環中每個代碼創建的進度條/標籤?
Sub festplatte()
Dim allDrives() As DriveInfo = DriveInfo.GetDrives()
Dim d As DriveInfo
Dim I As Integer
For Each d In allDrives
If d.IsReady = True Then
Try
' Intelize controls
Dim progressbar As ProgressBar = New ProgressBar
Dim pbgroup As GroupBox = New GroupBox
Dim info As Label = New Label
Dim type As Label = New Label
Dim format As Label = New Label
Dim Space As Double = d.TotalFreeSpace/d.TotalSize
' Add to tab
Me.Tab_M.Controls.Add(progressbar)
Me.Tab_M.Controls.Add(pbgroup)
Me.Tab_M.Controls.Add(info)
Me.Tab_M.Controls.Add(type)
Me.Tab_M.Controls.Add(format)
' Add to group
pbgroup.Controls.Add(progressbar)
pbgroup.Controls.Add(info)
pbgroup.Controls.Add(type)
pbgroup.Controls.Add(format)
pbgroup.Text = d.Name & " | Name : " & CheckName(d.VolumeLabel.ToString())
pbgroup.Size = New System.Drawing.Size(600, 65)
pbgroup.Location = New System.Drawing.Point(8, I * 70 + 40)
' format
format.AutoSize = True
format.Name = "format" & I
format.Location = New System.Drawing.Point(435, 36)
format.Text = "Format : " & d.DriveFormat
' Typ
type.AutoSize = True
type.Name = "type" & I
type.Location = New System.Drawing.Point(435, 16)
type.Text = "Art : " & GetDriverFormat(d)
' info
info.Name = "info" & I
info.Location = New System.Drawing.Point(6, 16)
info.AutoSize = True
' Info Text :: 1000 MB Grenze
If d.TotalFreeSpace > Math.Pow(1024, 3) Then
info.Text = "Benutzter Speicher beträgt : " & Math.Round((d.TotalSize - d.TotalFreeSpace)/btogb, 2) & " GB von " & Math.Round((d.TotalSize)/btogb, 2) & " GB (" & Math.Round(100 - Space * 100, 2) & " %)"
Else
info.Text = "Benutzter Speicher beträgt : " & Math.Round((d.TotalSize - d.TotalFreeSpace)/btomb, 2) & " MB von " & Math.Round((d.TotalSize)/btomb, 2) & " MB (" & Math.Round(100 - Space * 100, 2) & " %)"
End If
'Progressbar
progressbar.Size = New System.Drawing.Size(425, 23)
progressbar.Location = New System.Drawing.Point(6, 32)
progressbar.Name = "Memory" & I
progressbar.Value = 100 - Space * 100
Catch ex As Exception
MsgBox(ex.ToString())
End Try
I += 1
End If
Next
End Sub
代碼中併產生與它每一個進度條和3個標籤,在這裏我想編輯東西組框。
如何編輯例如標籤的文本?我怎樣才能從表單中添加/刪除生成的元素?我試圖刷新,但它不工作
你想在標籤上寫什麼?磁盤名稱或%等可能會更新您的問題,並提供更多關於您想要執行的操作的信息。 – Creator 2014-12-06 23:35:00
並請發佈運行此代碼所需的代碼「有你的貼子以外的東西」CheckName和GetDriverFormat等 – Creator 2014-12-07 03:24:16
對不起:標籤應顯示驅動器的已用大小和使用的驅動器的百分比。功能:Checkname檢查卷標是否爲空或什麼(「」 - > Nothing)GetDriverFormat是一個帶有select case的函數,它只是轉換驅動器的格式(例如Fixed - > into german:Festplatte) – NoSenseSenpai 2014-12-07 19:13:33