Hello.

Ive got a listview with columns etc and ive managed to sort the coding out so when i open a form, fill in the details in the relevant box then press save it transfers some of that data into the relevant columns, which is great. However i would like it so when i press on the row (to select it) and then a button called 'View', i would like that report that was created earlier to show up with all the data still in it. Does that make sense?

Can anyone help me? It will be greatly appreciated. And also im not using any database for this.

Cheers

Recommended Answers

All 6 Replies

If you need to retrive the back to your textboxsthen you canuse the coding as this

  myConnection = New SqlConnection(connectionstring)
        myConnection.Open()

        myCommand = New SqlCommand(" Select * FROM [table name] Where P_Id='" & ComboBoXx.Text & "'", myConnection)
        Dim dr As SqlDataReader = myCommand.ExecuteReader
        While dr.Read()

            thenameofthe text box.Text = Val(dr(0))

            currentbalance = Double.Parse(dr(2).ToString)

        End While
        dr.Close()
        myConnection.Close()

If you need to retrive the data from table to textbox

 Public connectionString As String = "Data Source=HP-PC;Initial Catalog=VBP;user ID =sa; password= 1234"
 myConnection = New SqlConnection(connectionstring)
        myConnection.Open()

        myCommand = New SqlCommand(" Select Quantity FROM Product_Details Where P_Id='" & ComboBox2.Text & "'", myConnection)
        Dim dr As SqlDataReader = myCommand.ExecuteReader
        While dr.Read()

            TextBox4.Text = Val(dr(0))

            'currentbalance = Double.Parse(dr(2).ToString)

        End While
        dr.Close()
        myConnection.Close()

I haven't got a table nor do i have a database so i wont have a sqlconnection, is that right?

All i would like is to have items in a listview column, which i then select and the listview item opens up with the form with all the data in the boxes from that item.

If you want to pull the informaiton from a ListViewItem and display it in another form, then you just get the SelectedItem in the ListView.

Dim MySelectedItem = MyListView.SelectedItem

From there you can pull your data.

Dim MyFirstColumn As String = MySelectedItem.Text         ' This is the first column.
Dim MySecondColumn As String = MySelectedItem.SubItems(0) ' This is the second column.
Dim MyThirdColumn As String = MySelectedItem.SubItems(1)  ' This is the third column.

In ListViewItems, the first column is the ListViewItem itself. The SubItems are then added to the ListViewItem, and are 0 indexed based.

does that also include data that isnt displayed in the columns?

Ive tried this and it doesnt seem to work. Where do i put the codes, ie, which button etc

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.