hi all, here my problem is i'm preety new to vb.net programming. but have a little knowledge in vb6 programming. Say, when i press the 'edit' button a listview is shown, filled with records('empcode' field from empdetail) from a access table, say 'empdetail'. now if i doubleclick on a particuler record in the listview, then the listview will disappear and the records will be displayed in the textboxes. exactly what we do in vb6, the coding follows,cn is the connection to the db.

private sub listview1_dblclick()
  for i=1 to listview1.listitems.count
    if listview1.listitems(i).selected=true then
      dim rs as new adodb.recordset
      rs.cursorlocation=aduseclient
      rs.open "select * from empdetail where empcode='" & listview1.selecteditem & _ 
      "'",cn              
      if rs.recordcount>0 then
        text1.text=rs!empcode
        text2.text=rs!empname
        text3.text=rs!empaddress
        text4.text=rs!empdesignation
        listview1.visible=false
        text1.setfocus
        rs.close
        exit for
      else
        rs.close
        msgbox("......",vbokonly,"")
      end if
    end if
  next
end sub

now i want to do exactly the same thing with vb.net, please give me the sample coding, because i know the logic but not familier with vb.net syntax.now if i click on the listview, it's being hung. any help is appricieted, thank u again

Edited 6 Years Ago by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

Jumba, I have asked to move the post to .Net, I am sure the experts on .net will be able to help you out.

Good luck.

Hi to all of my frnds, n thank you so much dat you've started looking into this issue. but my frnds, i'm still stuck with the issue n i tried to find answres that can help me in google, n you can say, all possible efforts i already put into solving this, but seems like vb6 n vb.net is preety different(atleast conceptwise). please my frnds, help me to get rid of this issue. and if you know, please provide with sample codes, if possible, that'll even help me a lot to learn it(may be master it by myself).thank you all my dear frnds, u all have been very nice people.have a great time ahead......

I am not quite clear of what you are trying to achieve, except that you want to double click an item in a Listview and get the values of a item and subitems in a row.

If I am on the right path, the following code snippet should help.

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With ListView1
            .Columns.Add("col 1", 55) : .Columns.Add("col 2", 100) : .Columns.Add("col 3", 75)
            .View = View.Details : .FullRowSelect = True
            Dim newItem As New ListViewItem
            newItem.Text = "empcode"
            newItem.SubItems.Add("empcode details")
            newItem.SubItems.Add("empcode address")
            .Items.Add(newItem)
            Dim newItem2 As New ListViewItem
            newItem2.Text = "empname"
            newItem2.SubItems.Add("empname details")
            newItem2.SubItems.Add("empname address")
            .Items.Add(newItem2)
        End With
    End Sub

    Private Sub ListView1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDoubleClick
        Dim selItem As String = ListView1.SelectedItems.Item(0).Text
        Dim selItemSub1 As String = ListView1.SelectedItems.Item(0).SubItems(1).Text
        Dim selItemSub2 As String = ListView1.SelectedItems.Item(0).SubItems(2).Text
        MsgBox("selected row: " & ListView1.SelectedItems.Item(0).Index + 1 _
               & vbCrLf & selItem & " - " & selItemSub1 & " - " & selItemSub2)
    End Sub

End Class

hi codeorder, thank u so much for ur help, u r such a lovely person. I didn't test this piece of code however i feel to let u know what i want in detail. here i go,
say, a listview is displayed and it has 2 columns, 1st is employee code(which is unique), 2nd is corresponding employee name. and i have a table namely 'empdetails'. ok? now in that table i have the details of each employee, say, employee's address, mail-id, phone no,bloodgroup,qualification etc. the empcode and corresponding empname that r shown in the listview, r definitely taken from the same table but when i'm dblclicking on a specific item from the listview, that pariculer empcode will be searched in 'empdetails' by using sql query "select * from empdetails where empcode='" and then that particuler empcode selected in the listview. this way i can pull the details of that empcode. isn't it? now i'll take and fill the textboxes with the desired columns from the table(the selected record in the table), assume, qualification, phone no,email-id against the selected empcode from the listview. got it? now exactly this is what i want to do against listview's doubleclick event.plssss dear frnd, help me out, i really need this but i 'm a newbie to vb.net's world.Thank u a lot again, God bless u all

I am sorry that I cannot be of further assistance due to the fact that I do not have any knowledge of using Sql Query or anything that has to do with Databases.

The code sample I have previously posted should give you a start at getting the information needed to search for the Employee Details.

Edited 6 Years Ago by codeorder: n/a

Thank u Dani, thank u all guys, now i've been a bit used to in vb.net. I've a new question here n ineed to know this. please guys, help me out as soon as possible. the Question is-
i've taken data/records from a dataset to a datagrid. now i've made changes in few rows(updated/edited) in the datagrid. how can i now send all the records/data from the datagrid to the dataset back without using any loop(i'm not supposed to use any loop here)?
i need both the logic and sample coding. any help is appriciated in advance. pls friends, i need to know this very soon. God bless u all, take care n stay happy.

Hello
i study the code that you post in forum but in my project does not work.
in my form i have added an listview,this listview display products.by clicking any of products i want to display in the textboxes (that are in this form)all the information about this product.of course the information is stored in ms acess and from there to be displayed in textboxes all the informations
can anyone help me please?

This article has been dead for over six months. Start a new discussion instead.