01-01-19, 04:45 AM
(01-01-19, 02:52 AM)allo5_800 كتب : اشكرك اخي ولاكن المطلوب ملف تكست وليس تكست بكس اي تصديره الى ملف txt يحفظ على الجهاز انا استخدمت كود لاكن يقوم بتكرير القيمة بالسط الواحد ثلاث مرات اليك الكود لتوضح عندك الصور
اعتذر لاني لم اقم بتوضيح الطلب اكثر
كود :
Private Sub SimpleButton2_Click_1(sender As Object, e As EventArgs) Handles SimpleButton2.Click
Dim sfg As New SaveFileDialog
sfg.FileName = ""
sfg.Filter = "text document|*.txt"
sfg.Title = "save datagridview as"
If sfg.ShowDialog = DialogResult.OK Then
Dim writer As TextWriter = New StreamWriter(sfg.FileName)
For i As Integer = 0 To DataGridView1.Rows.Count - 1
For j As Integer = 0 To DataGridView1.Columns.Count - 1
writer.Write(DataGridView1.Rows(i).Cells(1).Value.ToString() & "," & DataGridView1.Rows(i).Cells(3).Value.ToString())
Next
writer.WriteLine("")
Next
writer.Close()
MsgBox("تم تصدير المف")
End If
End Sub
في كود رد الاخ الكريم قم بتغيير file.txt التي في اخر سطر الي المسار الذي تريده


