26-03-19, 12:54 PM
السلام عليكم ورحمة الله وبركاته أعضاء المنتدي الكرام
لدي هذا الكود الذي يقوم بحفظ datagridview إلى ملف نصي
أرجو مساعدتي في إعادة جلب هذا الملف إلى datagridview ثانية أي العملية العكسية
بارك الله فيكم
لدي هذا الكود الذي يقوم بحفظ datagridview إلى ملف نصي
أرجو مساعدتي في إعادة جلب هذا الملف إلى datagridview ثانية أي العملية العكسية
بارك الله فيكم
كود :
Using Dilaoge As New SaveFileDialog
Dilaoge.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
If Dilaoge.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim NomFechiers As String = Dilaoge.FileName
Dim StreamW As StreamWriter = File.CreateText(NomFechiers)
Dim total = (From x As DataGridViewRow In DGView.Rows Select CDbl(x.Cells(4).Value)).Sum
StreamW.WriteLine("" & DGView.RowCount & "" & Today.ToLongDateString & "" & FormatNumber(total))
Dim Cellule1, Cellule2, Cellule3, Cellule4 As String
For i As Integer = 0 To DGView.Rows.Count - 1
Cellule2 = (DGView.Rows(i).Cells(2).Value.ToString().PadLeft(5, "0") & "")
Cellule3 = (DGView.Rows(i).Cells(3).Value.ToString() & "")
Cellule4 = (DGView.Rows(i).Cells(4).Value.ToString() & "")
Cellule1 = (DGView.Rows(i).Cells(1).Value.ToString().PadLeft(27))
StreamW.Write(Cellule2 & "" & Cellule3 & "" & GetFormatNumber(Cellule4) & "" & Cellule1)
StreamW.WriteLine("")
Next
StreamW.Close()
MessageBox.Show("تمت عملية الحفظ بنجاح")
End If
End Using