cayongrayoo
Member
- Joined
- Feb 8, 2012
- Messages
- 9
- Programming Experience
- Beginner
Hi i'm trying to move a row from a datagridview(caches) to another datagridview(chosen). The user clicks a button on the row he/she wants and it moves to the other datagridview(chosen).
The first datagridview(caches) uses a dataset as its data source.
So far my program clones the row of which the button is pressed, into a datagridviewrow(row).
It then adds the columns from the first datagridview(caches) to the new datagridview(chosen).
But when I try and put the cloned row into the first row I get: Property 'item' is read only.
Here is my code:
Private Sub cacheList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cacheList.Click caches.Visible = True
caches.DataSource = Ds.Tables(3)
Dim btn As New DataGridViewButtonColumn()
caches.Columns.Add(btn)
btn.HeaderText = "Click Data"
btn.Text = "Click Here"
btn.Name = "btn"
btn.UseColumnTextForButtonValue = True
End Sub
Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles caches.CellClick
Dim row As DataGridViewRow
chosen.ColumnCount = 15
chosen.Columns(0).Name = caches.Columns(0).Name
If e.RowIndex = 3 Then
row = caches.Rows(3).Clone
chosen.Rows(0) = row
End If
Any help is massively appreciated.
The first datagridview(caches) uses a dataset as its data source.
So far my program clones the row of which the button is pressed, into a datagridviewrow(row).
It then adds the columns from the first datagridview(caches) to the new datagridview(chosen).
But when I try and put the cloned row into the first row I get: Property 'item' is read only.
Here is my code:
Private Sub cacheList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cacheList.Click caches.Visible = True
caches.DataSource = Ds.Tables(3)
Dim btn As New DataGridViewButtonColumn()
caches.Columns.Add(btn)
btn.HeaderText = "Click Data"
btn.Text = "Click Here"
btn.Name = "btn"
btn.UseColumnTextForButtonValue = True
End Sub
Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles caches.CellClick
Dim row As DataGridViewRow
chosen.ColumnCount = 15
chosen.Columns(0).Name = caches.Columns(0).Name
If e.RowIndex = 3 Then
row = caches.Rows(3).Clone
chosen.Rows(0) = row
End If
Any help is massively appreciated.