08-02-17, 04:38 PM
السلام عليكم
اخي الفاضل هذا مثال يوضح فكرة تحميل ملفات معينة في اداة كمبوبوكس ومن ثم قراءة تلك الملفات وعند الإغلاق
يحفظ اخر ملف تم إختياره من الكمبوبوكس.
اخي الفاضل هذا مثال يوضح فكرة تحميل ملفات معينة في اداة كمبوبوكس ومن ثم قراءة تلك الملفات وعند الإغلاق
يحفظ اخر ملف تم إختياره من الكمبوبوكس.
PHP كود :
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
'تحميل الملفات
Dim dir = Application.StartupPath & "\New folder"
For Each file As String In System.IO.Directory.GetFiles(dir)
ComboBox1.Items.Add(System.IO.Path.GetFileNameWithoutExtension(file))
Next
'تحديد اخر قيمة تم اختيارها قبل اغلاق الفورم
ComboBox1.SelectedIndex = My.Settings.file_name
Catch ex As Exception
End Try
End Sub
PHP كود :
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
'قراءة الملفات
If ComboBox1.SelectedIndex <> -1 Then
Dim path_ As String = Application.StartupPath & "\New folder\" & ComboBox1.Text & ".txt"
RichTextBox1.LoadFile(path_, RichTextBoxStreamType.PlainText)
'حفظ قيمة الملف الذي تم اختياره من الكمبوبوكس
My.Settings.file_name = ComboBox1.SelectedIndex
My.Settings.Save()
End If
End Sub

