help with listview

i'm currently building an app with vb.net
and i'm having some problems with a listview and item activation, i don't understand the mechanics of it
what i want is to double click on an listview item and show a form
i've been searching in msdn but i don't seem to understand how it works

any help would be appreciated


Answer this question

help with listview

  • bforst

    it works now.....thanks for the help

  • Simeao

    To double click and show a form, you need to have a look at ListView Mouse Event, eg: MouseDown.

    In listview, Me.Listview1.selectedIndices(0) only return an Integer that if you set multi-select = False.

    Or else, you might have to use looping to get the Indices that were selected.


    Private Sub ListView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDown

    If e.Clicks = 2 AndAlso Me.ListView1.SelectedItems.Count > 0 Then

    MsgBox(Me.ListView1.Items(Me.ListView1.SelectedIndices(0)).Text)

    End If

    End Sub



  • vishwas_udy

    the thing is that i need not only one form to open, but several
    your code is a big help, but i have a problem with it
    i've trying variations of your code and i'm stuck...........
    if i try this, only the first part of the code runs, so to say only formopenemp is opened, the second form doesn't, it opens only the first form

    If e.Clicks = 2 AndAlso Me.ListViewcons.Items(0).Text Is "Abrir" Then
    Dim openemp As New Formopenemp()
    openemp.MdiParent = Formopenemp.ActiveForm
    openemp.Show()
    ElseIf e.Clicks = 2 AndAlso Me.ListViewcons.Items(1).Text = "Criar" Then
    Dim cremp As New Formcreatedbemp()
    cremp.MdiParent = Formcreatedbemp.ActiveForm
    cremp.Show()
    end if
    any help would be appreciated

  • Sudheer_sgk

    Because you are trying to do it in MDI. You can't use "Is" in here. You have to use "="

    If e.Clicks = 2 AndAlso Me.ListView1.SelectedItems.Count > 0 Then

    If UCase(Me.ListView1.Items(Me.ListView1.SelectedIndices(0)).Text) = "1" Then

    Dim a As New Form2

    a.MdiParent = a.ActiveForm

    a.Show()

    ElseIf UCase(Me.ListView1.Items(Me.ListView1.SelectedIndices(0)).Text) = "2" Then

    Dim b As New Form3

    b.MdiParent = b.ActiveForm

    b.Show()

    End If

    End If



  • help with listview