Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
how to get index0 to index3 of row from datagridview1 and put in to the datagridview2
<img src="http://i144.photobucket.com/albums/r170/acidsnake20/form1.jpg" border="0" alt="Photobucket">
Posted
Updated 10-Nov-11 22:15pm
v2

1 solution

Private Function CreateDataTable() As DataTable
Dim myDataTable As DataTable = New DataTable()
Dim myDataColumn As DataColumn

myDataColumn = New DataColumn()
myDataColumn.DataType = Type.GetType("System.String")
myDataColumn.ColumnName = "Date"
myDataTable.Columns.Add(myDataColumn)

myDataColumn = New DataColumn()
myDataColumn.DataType = Type.GetType("System.String")
myDataColumn.ColumnName = "Time"
myDataTable.Columns.Add(myDataColumn)

Return myDataTable
End Function

Private Sub AddDataToTable(ByVal Date As String, ByVal Time As String)
Dim row As DataRow
row = myTable.NewRow()
row("Date") = Date
row("Time") = Time
myTable.Rows.Add(row)
End Sub


Now you can pass the rows from index 0 to 3
or add a select button on grid to add record in that datatable and bind that datatable with datagridview2
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900