Add rows from one datagridview to another
-
I am building a windows app to that will keep track of customers, quotes, orders and so forth using VB in visual studio 2005. I have a master-detail form that contains a Quoteheader and Quoteline datagridview that where the users can add products, price, number and so forth. I have also created another form (product search) that enables users to easily filter and search for products to pick the product(s) they want to add to the quote using a checkbox that I added to each row in the grid. (The data for this datagridview is pulled from a seperate dataset based on a view that contains, among other things, the info I need to transfer to the quoteline datagridview). Specifically I want to insert a new row in the Quoteline datagridview on the Quoteform where I automatically add the following field values (articleID, price per unit and costprice) from the product search datagridview to their respective column cells on the quoteline datagridview. It should insert a new row in the qoteline datagridview for each product that is selected using the checkbox on the product search form. I would like some help and advice on how to best code this operation.
-
I am building a windows app to that will keep track of customers, quotes, orders and so forth using VB in visual studio 2005. I have a master-detail form that contains a Quoteheader and Quoteline datagridview that where the users can add products, price, number and so forth. I have also created another form (product search) that enables users to easily filter and search for products to pick the product(s) they want to add to the quote using a checkbox that I added to each row in the grid. (The data for this datagridview is pulled from a seperate dataset based on a view that contains, among other things, the info I need to transfer to the quoteline datagridview). Specifically I want to insert a new row in the Quoteline datagridview on the Quoteform where I automatically add the following field values (articleID, price per unit and costprice) from the product search datagridview to their respective column cells on the quoteline datagridview. It should insert a new row in the qoteline datagridview for each product that is selected using the checkbox on the product search form. I would like some help and advice on how to best code this operation.
I'm assuming that your datagridview controls are datatable driven. If so, you can create a default view from the product search table while setting a rowfilter on the check box column. Then set the datasource table of the quoteline datagridview equal to this default view.
-
I'm assuming that your datagridview controls are datatable driven. If so, you can create a default view from the product search table while setting a rowfilter on the check box column. Then set the datasource table of the quoteline datagridview equal to this default view.
I'm not sure, but I don't think what u are suggesting is quite what i am looking for. what i am looking for is the vb.net syntax for how to do something like this: dim aricleid as integer dim productname as string dim productprice as string select articleid, productname, productprice from productsearchform.datagridview where checkboxcolumn.checked=true insert into quoteline.datagridview articleidcolumn, productnamecolumn, productpricecolumn with values (get the declared values from above code) articleid, productname, productprice continue to next row until all rows on the on the productsearch datagrid that have been checked have been inserted as new rows in the quoteline datagridview. Is there a good way to do this?
-
I'm not sure, but I don't think what u are suggesting is quite what i am looking for. what i am looking for is the vb.net syntax for how to do something like this: dim aricleid as integer dim productname as string dim productprice as string select articleid, productname, productprice from productsearchform.datagridview where checkboxcolumn.checked=true insert into quoteline.datagridview articleidcolumn, productnamecolumn, productpricecolumn with values (get the declared values from above code) articleid, productname, productprice continue to next row until all rows on the on the productsearch datagrid that have been checked have been inserted as new rows in the quoteline datagridview. Is there a good way to do this?
Assume for example, productsearchform.datagridview.datasource = datatableproductsearchform quoteline.datagridview.datasource = datatablequoteline Try this approach: datatableproductsearchform.defaultview.rowfilter = "checkboxcolumn = true" datatablequoteline = datatableproductsearchform.defaultview.totable Or this approach: Add this code to productsearchform.datagridview selectedindexchanged event if productsearchform.SelectedRow.Cells.Item(0).Text = true dim datarownew as datarow datarownew = datatablequoteline.newrow 'use the following code to populate the fields, one per field in datatablequoteline datarownew.item("[field name]") = productsearchform.SelectedRow.Cells.Item(1).Text datatablequoteline.rows.add(datatownew) end if
-
Assume for example, productsearchform.datagridview.datasource = datatableproductsearchform quoteline.datagridview.datasource = datatablequoteline Try this approach: datatableproductsearchform.defaultview.rowfilter = "checkboxcolumn = true" datatablequoteline = datatableproductsearchform.defaultview.totable Or this approach: Add this code to productsearchform.datagridview selectedindexchanged event if productsearchform.SelectedRow.Cells.Item(0).Text = true dim datarownew as datarow datarownew = datatablequoteline.newrow 'use the following code to populate the fields, one per field in datatablequoteline datarownew.item("[field name]") = productsearchform.SelectedRow.Cells.Item(1).Text datatablequoteline.rows.add(datatownew) end if
Hi Dptalt, The last approach seems to be what I have been looking for. I'll give it a shot later today. Appreciate your help.:) best regards, Hans