Solved

Move selected Items from datagridview1 to another datagridview2

Posted on 2011-02-11
11
242 Views
Last Modified: 2012-08-13
I have datagridview1  bound to a database I want to select items from here then transfer them to Datagridview2
0
Comment
Question by:teogos
  • 9
  • 2
11 Comments
 

Author Comment

by:teogos
ID: 34870992
I am using windows forms visual basic
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34871077
0
 

Author Comment

by:teogos
ID: 34871132
I will try, but I was looking for something simpler like on the CellContentClick,  I just have three colummns to transfer
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:teogos
ID: 34873807
Does not work, will not tranfer
0
 

Author Comment

by:teogos
ID: 34887640
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
 

Author Comment

by:teogos
ID: 34890960
Increasing points

0
 

Author Comment

by:teogos
ID: 34898143
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
 

Author Comment

by:teogos
ID: 34915379
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
 

Author Comment

by:teogos
ID: 34915582
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
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 35022060
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
 

Author Closing Comment

by:teogos
ID: 35055233
Sorry, took me a while to get back, Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question