Link to home
Start Free TrialLog in
Avatar of teogos
teogosFlag for United States of America

asked on

Move selected Items from datagridview1 to another datagridview2

I have datagridview1  bound to a database I want to select items from here then transfer them to Datagridview2
Avatar of teogos
teogos
Flag of United States of America image

ASKER

I am using windows forms visual basic
Avatar of teogos

ASKER

I will try, but I was looking for something simpler like on the CellContentClick,  I just have three colummns to transfer
Avatar of teogos

ASKER

Does not work, will not tranfer
Avatar of teogos

ASKER

Can you provide me with some code samples

Datagridview1   is the bound data table and datagridview2 is the one I want to transfer the selected records

Datagridview1 has    Prod_Code ,  Boxes, Lbs   those are the ones I want to transfer to 2
Avatar of teogos

ASKER

Increasing points

Avatar of teogos

ASKER

I got to this far, the data is being transfer to datagridview2 using the code below


For Each dgvRow As DataGridViewRow In DataGridView1.SelectedRows
            Dim dgvNewRow As New DataGridViewRow
            dgvNewRow.CreateCells(DataGridView2)

            dgvNewRow.Cells(0).Value = dgvRow.Cells("ProdCodeDataGridViewTextBoxColumn").Value
            dgvNewRow.Cells(1).Value = dgvRow.Cells("BoxesDataGridViewTextBoxColumn").Value
            dgvNewRow.Cells(2).Value = dgvRow.Cells("LbsDataGridViewTextBoxColumn").Value

            DataGridView2.Rows.Add(dgvNewRow)
        Next


but since datagridview1 is a databound to a database is getting refresh on a timer based, but  datagridview2 is not getting new data for the previous selected records,

How Can get the new values for the
            dgvNewRow.Cells(1).Value = dgvRow.Cells("BoxesDataGridViewTextBoxColumn").Value
            dgvNewRow.Cells(2).Value = dgvRow.Cells("LbsDataGridViewTextBoxColumn").Value

that are happening on Datagridview1 to datagridview2  based on the previous selected records
Avatar of teogos

ASKER

Changing the layout.
If I have a Bound datagrid. and how Can I fliter multiple items   something like a Check box to select items and by checking this box the items will be the filters
Avatar of teogos

ASKER

I have found this. to filter the  DatagridView

Dim dv As DataView = Me.BEEF.Tables("BEEFREGULAR").DefaultView
        dv.RowFilter = "Prod_Code='" & Me.ComboBox1.Text & "'"
        DataGridView1.DataSource = dv

This works, but  only one record  each time,I want to be multiple select on the combobox1 then filter the datagridview with the selections
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of teogos

ASKER

Sorry, took me a while to get back, Thanks