Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

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
0
teogos
Asked:
teogos
  • 9
  • 2
1 Solution
 
teogosAuthor Commented:
I am using windows forms visual basic
0
 
teogosAuthor Commented:
I will try, but I was looking for something simpler like on the CellContentClick,  I just have three colummns to transfer
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
teogosAuthor Commented:
Does not work, will not tranfer
0
 
teogosAuthor Commented:
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
0
 
teogosAuthor Commented:
Increasing points

0
 
teogosAuthor Commented:
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
0
 
teogosAuthor Commented:
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
0
 
teogosAuthor Commented:
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
0
 
CodeCruiserCommented:
You can use the checkboxes to allow user to make multiple selections. You would then need to construct a filter string using something like this

Dim filter as sting
if cb1.checked then
   filter = "column1=val1"
end if
if cb2.checked then
   filter &= "and column2=val2"
end if
...

filter = filter.trim.trim("a").trim("n").trim("d").trim

dv.rowfilter = filter
0
 
teogosAuthor Commented:
Sorry, took me a while to get back, Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 9
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now