منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : كيفية نقل بيانات من Textbox الى الجريدفيو بالترتيب؟؟
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
السلام عليكم ورحمة الله وبركاته 

اسعد الله اوقاتكم اخواني الاعزاء

سؤالي : كيف يمكن نقل بيانات من مجموعة تكس بوكس لها خاصية ال MULTILINE 

بحيث جميع  بيانات السطر الاول لكل تكس بوكس ينتقل الى الصف الاول في الجريد فيو
وبيانات الصف الثاني لكل التكس بوكس ينتقل الى الصف الثاني في الجريدفيو و................هكذا

الصورة المرفقة توضح المطلوب:

[attachment=29109]

استخدمت هذا الكود ولكن لم ينفع

        DataGridView1.Rows.Clear()
        On Error Resume Next
        For i As Integer = 0 - 1 To DataGridView1.Rows.Add
            DataGridView1.Rows.Item(i).Cells(0).Value = TextBox1.Lines(0).ToString
            DataGridView1.Rows.Item(i).Cells(1).Value = TextBox1.Lines(0).ToString
            DataGridView1.Rows.Item(i).Cells(2).Value = TextBox1.Lines(0).ToString
            DataGridView1.Rows.Item(i).Cells(3).Value = TextBox1.Lines(0).ToString
            DataGridView1.Rows.Item(i).Cells(0).Value = TextBox1.Lines(1).ToString
            DataGridView1.Rows.Item(i).Cells(1).Value = TextBox1.Lines(1).ToString
            DataGridView1.Rows.Item(i).Cells(2).Value = TextBox1.Lines(1).ToString
            DataGridView1.Rows.Item(i).Cells(3).Value = TextBox1.Lines(1).ToString
            DataGridView1.Rows.Item(i).Cells(0).Value = TextBox1.Lines(2).ToString
            DataGridView1.Rows.Item(i).Cells(1).Value = TextBox1.Lines(2).ToString
            DataGridView1.Rows.Item(i).Cells(2).Value = TextBox1.Lines(2).ToString
            DataGridView1.Rows.Item(i).Cells(3).Value = TextBox1.Lines(2).ToString
       Next
        
ارجو التكرم بالتعديل على الكود علما بأن عدد الاسطر في التكس بوكس غير محدد
???????????????????????????????????????????
????????????????????????????????????????؟؟؟ Blush Huh Huh
مرحبا بك أخي abu7shihab
أعتقد في حالة برنامجك هذا ! الأفضل برمجيا استخدام أداة ListBox بدلا من استخدام TextBox
[attachment=29118]

الكود بالصورة اعلاه
كود :
Public Class Form1
   Private Sub btnAddToGrid_Click(sender As Object, e As EventArgs) Handles btnAddToGrid.Click
       ' Split the lines of text in each TextBox and extract the first lines.
       Dim textBox1Lines As String() = TextBox1.Text.Split(New String() {Environment.NewLine}, StringSplitOptions.None)
       Dim textBox2Lines As String() = TextBox2.Text.Split(New String() {Environment.NewLine}, StringSplitOptions.None)
       Dim textBox3Lines As String() = TextBox3.Text.Split(New String() {Environment.NewLine}, StringSplitOptions.None)

       ' Find the maximum number of lines among the TextBoxes.
       Dim maxLinesCount As Integer = Math.Max(Math.Max(textBox1Lines.Length, textBox2Lines.Length), textBox3Lines.Length)

       ' Create a DataTable to hold the data to be displayed in the DataGridView.
       Dim dt As New DataTable()
       dt.Columns.Add("TextBox1")
       dt.Columns.Add("TextBox2")
       dt.Columns.Add("TextBox3")

       ' Loop through each line and add the first lines to the DataTable.
       For i As Integer = 0 To maxLinesCount - 1
           Dim row As DataRow = dt.NewRow()
           If i < textBox1Lines.Length Then
               row("TextBox1") = textBox1Lines(i)
           End If
           If i < textBox2Lines.Length Then
               row("TextBox2") = textBox2Lines(i)
           End If
           If i < textBox3Lines.Length Then
               row("TextBox3") = textBox3Lines(i)
           End If
           dt.Rows.Add(row)
       Next

       ' Bind the DataTable to the DataGridView to display the data.
       DataGridView1.DataSource = dt
   End Sub
End Class