تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
هل ممكن عمل load لى ملف
#1
هل يمكن عمل Save لى items الى فى combobox يعنى لو عملت add بى استخدام هذا الكود
ComboBox1.Items.Add(TextBox1.Text)
هل يمكن عمل Save لى items الى تم وضعه بعد اغلاق المشروع؟
الرد }}}
تم الشكر بواسطة:
#2
مثلآ عندى 1 button و 1 Combobox و 1 TextBox فى Button كود
كود :
ComboBox1.Items.Add(TextBox1.Text)
مفروض لو وضعت كلمه فى Text وى ضغط على button هاتظهر فى Combobox انا اريد اضافت الكلمف فى ملف NotePad يوجد فى فولدير المشروع يعنى لو عملت add لى كلمة تىضاف فى ComboBox وى NotePad وى عند مسح كلمه من Combobox تتمسح من NotePad وى عند غلق المشروع وى فتحه تانى ComboBox ياخذ Items الى كانت مكتوبه فى قبل غلق المشروع من ملف NotePad
الرد }}}
تم الشكر بواسطة:
#3
كود :
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim Arr(ComboBox1.Items.Count - 1) As String
ComboBox1.Items.CopyTo(Arr, 0)
IO.File.WriteAllLines("Data.txt", Arr)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If My.Computer.FileSystem.FileExists("Data.txt") Then
ComboBox1.Items.AddRange(IO.File.ReadAllLines("Data.txt"))
End If
End Sub


بالتوفيق
[SIZE=6]لا إله إلا أنت سبحانك إني كنت من [/SIZE][SIZE=6]الظالمين[/SIZE][SIZE=6]
[/SIZE]
الرد }}}
تم الشكر بواسطة:
#4
Osama_Ghareeb كتب :
كود :
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim Arr(ComboBox1.Items.Count - 1) As String
ComboBox1.Items.CopyTo(Arr, 0)
IO.File.WriteAllLines("Data.txt", Arr)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If My.Computer.FileSystem.FileExists("Data.txt") Then
ComboBox1.Items.AddRange(IO.File.ReadAllLines("Data.txt"))
End If
End Sub


بالتوفيق

جزاك الله كل خير أخى
أخى كيف يمكن عند اضافت New Item لو وجد Item فى Combobox يظهر رساله هذا الكلمه موجوده من قبل
الرد }}}
تم الشكر بواسطة:
#5
كود :
If ComboBox1.Items.Contains([color=#ff0000]"1"[/color]) Then
            MsgBox("موجود مسبقا")
        Else
            ComboBox1.Items.Add([color=#ff0000]"1"[/color])
        End If
[SIZE=6]لا إله إلا أنت سبحانك إني كنت من [/SIZE][SIZE=6]الظالمين[/SIZE][SIZE=6]
[/SIZE]
الرد }}}
تم الشكر بواسطة:
#6
Osama_Ghareeb كتب :
كود :
If ComboBox1.Items.Contains([color=#ff0000]"1"[/color]) Then
            MsgBox("موجود مسبقا")
        Else
            ComboBox1.Items.Add([color=#ff0000]"1"[/color])
        End If
جزاك الله كل خير أخى
الرد }}}
تم الشكر بواسطة:



التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم