我在下面有这个代码。这是发生了什么以及我做了什么:
有没有办法如何* 清除 openfiledialog,以便消息框只显示一次。
顺便说一下,这是我的代码:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles BtnBrowse.Click
'Limits the number of photos to 10
AddHandler OpenFileDialog1.FileOk, Sub(s, ce)
If OpenFileDialog1.FileNames.Length > 10 Then
MsgBox("Only 10 photos are needed.")
ce.Cancel = True
End If
End Sub
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
Dim images As String
For Each images In OpenFileDialog1.FileNames
Dim pics As New PictureBox
'Sets the properties of the picturebox in the TableLayoutPanel
pics.Height = 120
pics.Width = 120
pics.SizeMode = PictureBoxSizeMode.StretchImage
pics.Image = Image.FromFile(images)
pics.Load(images)
'Add every images uploaded using the OpenFileDialog
TableLayoutPanelNitrogen.Controls.Add(pics)
'Sets the course of action based on the number of controls within the TableLayoutPanel
If TableLayoutPanelNitrogen.Controls.Count < 10 Then
Continue For
ElseIf TableLayoutPanelNitrogen.Controls.Count = 10 Then
BtnBrowse.Enabled = False
Exit For
ElseIf TableLayoutPanelNitrogen.Controls.Count > 10 Then
Exit For
End If
Next images
End If
End Sub