12-03-13, 04:42 AM
محمد كتب :اريض اضافه file فى listbox اذا كان هذا الملف موجود مسبقن فى listbox لا يتم اضافته
جربت هذا الكود
كود :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
If ListBox1.Items.Add(OpenFileDialog1.FileName) Then
MsgBox("خطاء")
Else
ListBox1.Items.Add(OpenFileDialog1.FileName)
End If
End Sub
كود :
If Listbox1.Items.Contains(OpenFileDialog1.FileName) Then
MsgBox("Cannot add the File " & OpenFileDialog1.FileName, MsgBoxStyle.Information)
Else
Listbox1.Items.Add(OpenFileDialog1.FileName)
