steviebernstein
Member
- Joined
- Oct 9, 2009
- Messages
- 14
- Programming Experience
- Beginner
So my final goal is to take some columns from one form's datagridview (in form3) and place them into a seperate form's datagridview (form4). I started off by just trying to put all of the rows in there one-by-one. Later I will be moe picky about which rows I want. Below is the code I am using. The problem is that I am ending up with an empty form, but no errors. Thank you for your input.
Code:
Code:
VB.NET:
Public Class Form4
Inherits System.Windows.Forms.Form
Dim frmInstance As New Form3()
Public Sub Populate_A1_Data()
Try
With Me.DataGridViewA1
.Rows.Clear()
Dim ColumnCount2 As Integer = frmInstance.DataGridView1.ColumnCount
'MessageBox.Show(ColumnCount2) ' test to see if i counted the columns
For i As Integer = 0 To ColumnCount2 - 1
.Columns.Add(frmInstance.DataGridView1.Columns(i).Name, frmInstance.DataGridView1.Columns(i).Name)
Next
.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader
Dim RowCount As Integer = frmInstance.DataGridView1.RowCount
For i As Integer = 0 To RowCount - 1
Dim objCells1 As DataGridViewRow = frmInstance.DataGridView1.Rows(i).Clone
.Rows.Add(objCells1)
Next
End With
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
End Try
End Sub
Last edited by a moderator: