Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Listbox problem on doubleclick
Message
De
25/02/2005 10:37:47
Steve Jones
Business Systems Services Uk Ltd
Swansea, Royaume Uni
 
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
00990500
Message ID:
00990544
Vues:
14
Here is the code for the three events, along with the Sub procedure they all call.
Private Sub SelectButton_Click(ByVal Sender As Object, ByVal e As System.EventArgs) Handles btnSelect.Click
    Try
        Dim intSelectedIndex As Int16 = Me.lstAccounts.SelectedIndex
            ' If nothing is selected, perform search
            If intSelectedIndex < 0 Then
                Exit Sub
            End If
            ' Get the account number 
            AccountSelected(intSelectedIndex)

        Catch ex As Exception

        End Try
    End Sub

    Public Sub lstAccounts_DblClick(ByVal Sender As Object, ByVal e As System.EventArgs) Handles lstAccounts.DoubleClick
        Try
            Dim intSelectedIndex As Int16 = Me.lstAccounts.SelectedIndex
            ' If there are no items in the list box, exit and do nothing
            If intSelectedIndex < 0 Then
                Exit Sub
            End If
            ' Get the account number highlighted 
            AccountSelected(intSelectedIndex)

        Catch ex As Exception

        End Try
    End Sub

    Private Sub lstAccounts_KeyPress(ByVal Sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles lstAccounts.KeyPress
        If e.KeyChar = vbCr Then
            Try
                Dim intSelectedIndex As Int16 = Me.lstAccounts.SelectedIndex
                ' If there are no items in the list box, exit and do nothing
                If intSelectedIndex < 0 Then
                    Exit Sub
                End If
                ' Get the account number highlighted 
                AccountSelected(intSelectedIndex)
            Catch ex As Exception

            End Try
        End If
    End Sub

    Private Sub AccountSelected(ByVal intSelectedIndex As Int16)
        Dim strAccountNumber As String

        Try
            ' If there are any accounts in list, then set customer ref to be the
            ' highlighted account no
            strAccountNumber = CType(Me.lstAccounts.Items.Item(intSelectedIndex), String).Substring(1, 10)
            Me.strAccountNo = strAccountNumber
            ' Close the form
            Me.Close()
        Catch Ex As Exception

        End Try
    End Sub
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform