﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Copy selected row from one ListView to another</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 02:19:10 GMT</lastBuildDate><ttl>20</ttl><item><title>Copy selected row from one ListView to another</title><link>http://forum.strataframe.net/FindPost17637.aspx</link><description>&lt;FONT face=Arial color=#555555&gt;Hi Trent,&lt;/FONT&gt;&lt;P&gt;&lt;FONT face=Arial color=#555555&gt;I have Wizard which help the user to select different products. In the first page&amp;nbsp;the user can select the main product and in the second page I have a ListView to show some sub products and user can select any product via a check box. In the 3rd page I need to show only the selected items from the 1st and 2nd page into another ListView which is basically a copy from the second page. For the 3rd page I created another instant as ProductsMGRItemsBO_Totals which is basically the same instant from the 2nd page named: ProductsMGRItemsBO1. At the end I need to save the Product_FK into the Items table.&lt;BR&gt;In order to show all products that were selected in the 3rd page I did as follows:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff&gt;[codesnippet]&lt;BR&gt;&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt; loTempBO &lt;FONT color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;New&lt;/FONT&gt; HFALib.ProductsMGRItemsBO&lt;BR&gt;&lt;FONT color=#1111bb&gt;Dim RowIndex As Integer&lt;/FONT&gt;&lt;FONT color=#000000&gt;&lt;FONT color=#1111bb&gt; = 0&lt;BR&gt;Dim ProductColumn As Integer = 1&lt;/FONT&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;For&lt;/FONT&gt;&lt;FONT color=#000000&gt; i = 0 &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;To&lt;/FONT&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;Me&lt;/FONT&gt;&lt;FONT color=#000000&gt;.lvSubProducts.CheckedItems.Count - 1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RowIndex = &lt;FONT color=#0000ff&gt;Me&lt;/FONT&gt;.lvSubProducts.CheckedItems.Item(i).Index&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim&lt;/FONT&gt; RecordPK &lt;FONT color=#0000ff&gt;As&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;Integer&lt;/FONT&gt; = &lt;FONT color=#0000ff&gt;Me&lt;/FONT&gt;.lvSubProducts.Items(RowIndex).Tag&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; loTempBO.FillByPrimaryKey(RecordPK)&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If&lt;/FONT&gt; loTempBO.Count = 1 &lt;FONT color=#0000ff&gt;Then&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Me&lt;/FONT&gt;.ProductsMGRItemsBO_Totals.CopyDataFrom(loTempBO,MicroFour.StrataFrame.Business.BusinessCloneDataType.AppendDataToTableFromCompleteTable)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;If&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;Next&lt;BR&gt;&lt;/FONT&gt;loTempBO.Dispose()&lt;BR&gt;[/codesnippet]&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Verdana','sans-serif'"&gt;&lt;FONT face=Arial color=#555555&gt;I need you to tell me If by creating another temp BO like loTempBO so I can grab the selected record by its primary key from the second page, and then copy that into the ListView in the 3rd page is correct. Is there&amp;nbsp;a better way using SF somewhere that I missed. Otherwise it works just fine, just looking for a more efficient way if any. Of couse there is more&amp;nbsp;code into it&amp;nbsp;but I tried to show you the specific code only.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Verdana','sans-serif'"&gt;&lt;FONT face=Arial color=#555555&gt;Thanks,&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Verdana','sans-serif'"&gt;&lt;FONT color=#555555&gt;&lt;FONT face=Arial&gt;Doron&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Mon, 07 Jul 2008 09:35:25 GMT</pubDate><dc:creator>Doron Farber</dc:creator></item><item><title>RE: Copy selected row from one ListView to another</title><link>http://forum.strataframe.net/FindPost17676.aspx</link><description>Yes I can wait Trent, no big deal.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Doron</description><pubDate>Mon, 07 Jul 2008 09:35:25 GMT</pubDate><dc:creator>Doron Farber</dc:creator></item><item><title>RE: Copy selected row from one ListView to another</title><link>http://forum.strataframe.net/FindPost17672.aspx</link><description>Well,&amp;nbsp;I was going to, but it was going to turn into a disertation.&amp;nbsp; We will actually cover this during the class, so if you can wait 7 days, we can go over this while you are here and it will be far easier to explain.</description><pubDate>Mon, 07 Jul 2008 09:29:40 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Copy selected row from one ListView to another</title><link>http://forum.strataframe.net/FindPost17669.aspx</link><description>Hi Trent,&lt;BR&gt;&lt;BR&gt;Thanks for your reply.&lt;P&gt;[quote]I would have probably used a generic dictionary so that I have a central object that is used through all of the pages (which may hold a BO within it) but this way it just reduces code. [/quote]&lt;/P&gt;&lt;P&gt;Can you elaborate a little more of the above. Since I have some redundancy in some objects. For Instant in 3 BOs for now I created the same 3 custom properties etc...&lt;BR&gt;&lt;BR&gt;Regards,&lt;/P&gt;&lt;P&gt;Doron</description><pubDate>Mon, 07 Jul 2008 09:19:34 GMT</pubDate><dc:creator>Doron Farber</dc:creator></item><item><title>RE: Copy selected row from one ListView to another</title><link>http://forum.strataframe.net/FindPost17645.aspx</link><description>Well, in the code above you could have just used the Using operating instead of creating a variable.&amp;nbsp; Also, you should really turn Option Strict on so that you at least get a warning when trying to pass an object into an Integer, but better yet, an error (by default when Option Strict is on).&amp;nbsp; First, it will be faster since it will not have to automaticaly evaluate the types, secondly, it will prevent weak typing.&amp;nbsp; In regards to your code, I would have probably used a generic dictionary so that I have a central object that is used through all of the pages (which may hold a BO within it) but this way it just reduces code.&amp;nbsp; but your code will work, and if you have it working, then I would leave it alone aside from changing the variables into the using statement:&lt;/P&gt;&lt;P&gt;[codesnippet]Using bo As New HFALib.ProductsMGRItemsBO()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bo.FillbyPrimaryKey(...)&lt;BR&gt;End Using[/codesnippet]</description><pubDate>Sun, 06 Jul 2008 16:42:42 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>