Как переместить строку datagridview в другой datagridview в другой форме с помощью CSV datasource - VB.NET
Я использую CSV для загрузки данных и сохранения данных из DataGridView, который у меня есть в форме. Теперь я хотел бы, чтобы с помощью события нажатия кнопки я мог отправить строку, отмеченную через столбец checkbox в DataGridView, в другой dataGridView, который размещен в другой форме.
Если это поможет, вот загрузка, которую я использую для загрузки и сохранения содержимого DataGridView.
Что я уже пробовал:
Private Sub btnLoadDGVGeneral_Click(sender As Object, e As EventArgs) Handles btnLoadDGVGeneral.Click ' PURPOSE: Load CSV file containing tasks into DataGridView ' Clearing DGV Rows allows for Tasks to not double up when rebooting the program dataGVGeneral.Rows.Clear() 'New Variable: fname, represents File Path of CSV as String Dim fname As String = "E:\SAT\Work.io\Work.io\bin\Debug\ListofTasks.csv" Dim reader As New StreamReader(fname, Encoding.Default) Dim sline As String = "" Dim colsexpected As Integer = 7 Dim r As Integer = 0 'StreamReader will the file Line by Line, and add it to the variable sline 'First sline statement is Out of Loop, as first line of CSV contains headings to what each figure represents in a line. sline = reader.ReadLine Do 'Now sline will read the 2nd line and so forth sline = reader.ReadLine 'If no value is found on that line of the CSV file (at the end), then the loop will exit If sline Is Nothing Then Exit Do 'Details is as a variable, which when called upon, places each value into different columns for that row Dim details() As String = sline.Split(",") dataGVGeneral.Rows.Add() For i As Integer = 0 To 6 dataGVGeneral.Rows(r).Cells(i).Value = details(i) Next 'Increments value of "r" by 1, meaning next line of CSV will be added to the next row. Dim v As Integer = r + 1 r = v Loop reader.Close() End Sub Private Sub btnSaveGeneralDGV_Click(sender As Object, e As EventArgs) Handles btnSaveGeneralDGV.Click Dim StrExport As String = "" For Each C As DataGridViewColumn In dataGVGeneral.Columns StrExport &= """" & C.HeaderText & """," Next StrExport = StrExport.Substring(0, StrExport.Length - 1) StrExport &= Environment.NewLine For Each R As DataGridViewRow In dataGVGeneral.Rows For Each C As DataGridViewCell In R.Cells If Not C.Value Is Nothing Then StrExport &= """" & C.Value.ToString & """," Else StrExport &= """" & "" & """," End If Next StrExport = StrExport.Substring(0, StrExport.Length - 1) StrExport &= Environment.NewLine Next Dim tw As System.IO.TextWriter = New System.IO.StreamWriter("E:\SAT\Work.io\Work.io\bin\Debug\ListofTasks.csv", False) tw.Write(StrExport) tw.Close() End Sub