How to retrieve details from listview to another listview


These are my codes for my first listview at the first form:

VB Code: Public Class RenewItem Private Sub txtName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtName.TextChanged End Sub Private Sub RenewItem_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =C:\temp\db1.mdb" Dim con As OleDb.OleDbConnection Dim dr As OleDb.OleDbDataReader Dim cmd As New OleDb.OleDbCommand Try Dim strselect As String = "Select * from return where BorrowerId = '" & Form1.txtBorrowerId.Text & "'" 'create a new connection con = New OleDb.OleDbConnection(strcon) con.Open() cmd.Connection = con cmd.CommandText = strselect dr = cmd.ExecuteReader If dr.Read Then txtName.Text = dr("memberName") txtId.Text = dr("BorrowerId") Dim Item As New ListViewItem Item.Text = (dr("itemId")) Item.SubItems.Add(dr("itemTitle")) Item.SubItems.Add(dr("dueDate")) lvrenew.Items.Add(Item) End If dr.Close() Catch eException As Exception ' MessageBox.Show(eException.Message) End Try lvrenew.View = View.Details 'view stuff in listview lvrenew.Columns.Add("Item Id", 80, HorizontalAlignment.Left) lvrenew.Columns.Add("Item Title", 200, HorizontalAlignment.Left) lvrenew.Columns.Add("Due Date", 80, HorizontalAlignment.Left) End Sub Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click Me.Close() End Sub Private Sub btnRenew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRenew.Click Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp\db1.mdb" Dim con As OleDb.OleDbConnection Dim dr As OleDb.OleDbDataReader Dim cmd As New OleDb.OleDbCommand Try Dim strsql As String = "Insert into newdueDate from return" 'create a new connection con = New OleDb.OleDbConnection(strcon) con.Open() cmd.Connection = con cmd.CommandText = strsql dr = cmd.ExecuteReader 'MsgBox("Item returned successfully!") Dim Item As New ListViewItem Item.Text = (dr("newdueDate")) 'Item.SubItems.Add(dr("itemTitle")) lvrenew.Items.Add(Item) dr.Close() Catch ex As Exception MessageBox.Show("Are you sure you want to renew the selected item(s)" & ControlChars.NewLine & "There is a fee of $0.50 for each item renewed.", "Msg", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) ItemRenewed.ShowDialog() End Try End Sub Private Sub lvrenew_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lvrenew.SelectedIndexChanged End SubEnd Class
These are my codes for my second listview at the second form:

VB Code: Public Class ItemRenewed Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click Me.Close() End Sub Private Sub ItemRenewed_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =C:\temp\db1.mdb" Dim con As OleDb.OleDbConnection Dim dr As OleDb.OleDbDataReader Dim cmd As New OleDb.OleDbCommand Try Dim strselect As String = "Select * from return where BorrowerId = '" & RenewItem.txtId.Text & "'" 'create a new connection con = New OleDb.OleDbConnection(strcon) con.Open() cmd.Connection = con cmd.CommandText = strselect dr = cmd.ExecuteReader If dr.Read Then txtName.Text = dr("memberName") txtId.Text = dr("BorrowerId") Dim Item As New ListViewItem Item.Text = (dr("itemId")) Item.SubItems.Add(dr("itemTitle")) Item.SubItems.Add(dr("newdueDate")) lvrenew.Items.Add(Item) End If dr.Close() Catch eException As Exception ' MessageBox.Show(eException.Message) End Try lvrenew.View = View.Details 'view stuff in listview lvrenew.Columns.Add("Item Id", 60, HorizontalAlignment.Left) lvrenew.Columns.Add("Item Title", 200, HorizontalAlignment.Left) lvrenew.Columns.Add("New Due Date", 100, HorizontalAlignment.Left) If Not RenewItem.lvrenew.SelectedItems.Count = 0 Then lvrenew = lvrenew.SelectedItems(0).count = 0 End Sub Private Sub lvrenew_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lvrenew.SelectedIndexChanged End SubEnd Class
I want the first listview selected items to be shown at the second listview.What should i doCan u give me codes as example
Posted On: Saturday 3rd of November 2012 12:50:22 PM Total Views:  203
View Complete with Replies