Solved

VB.net listbox. make all searches occur

Posted on 2016-08-28
4
37 Views
Last Modified: 2016-08-30
I have an identical action that needs to occur as in ID: 41772683 but this one uses listboxes. I have made the search boxes at the top populate according to whats typed in the CW column (using the search option bottom right)  but I cannot see how to emulate the enter keypress across the other columns programatically.

here is the first columns key up within this the search occurs

 Private Sub OnKeyUpCW(sender As Object, e As KeyEventArgs) Handles TextSearchCW.KeyUp, ListCW.KeyUp
        Dim index = -1

        If OPTagIndependant.Checked = True Then


        Else

            TextSearchAbi.Text = TextSearchCW.Text
            TextSearchCap.Text = TextSearchCW.Text
            TextSearchGlass.Text = TextSearchCW.Text
            TextSearchTvi.Text = TextSearchCW.Text

        End If

        If TypeOf sender Is TextBox Then
            Dim tb = DirectCast(sender, TextBox)
            If tb.Equals(TextSearchCW) Then
                If e.KeyCode.Equals(Keys.Enter) Then
                    index = ListCW.FindString(tb.Text)
                    If index <> -1 Then
                        ListCW.SetSelected(index, True)
                    End If
                    tb.Clear()
                    e.Handled = True
                End If
            End If
        ElseIf TypeOf sender Is ListBox Then
            Dim lb = DirectCast(sender, ListBox)
            If lb.Equals(ListCW) Then
                If e.KeyCode.Equals(Keys.Enter) Then
                    index = lb.FindString(TextSearchCW.Text)
                    If index <> -1 Then
                        lb.SetSelected(index, True)
                    End If
                    TextSearchCW.Clear()
                    e.Handled = True
                ElseIf e.KeyCode.Equals(Keys.Back) Then
                    If TextSearchCW.Text.Length > 0 Then
                        TextSearchCW.Text = TextSearchCW.Text.Substring(0, TextSearchCW.Text.Length - 1)
                    End If
                Else
                    TextSearchCW.Text = TextSearchCW.Text + Convert.ToChar(e.KeyCode)
                End If
            End If
        End If
    End Sub

Open in new window


Each of the others are within their own key up event.
    Private Sub OnKeyUpAbi(sender As Object, e As KeyEventArgs) Handles TextSearchAbi.KeyUp, ListAbi.KeyUp
        Dim index = -1
        If TypeOf sender Is TextBox Then
            Dim tb = DirectCast(sender, TextBox)
            If tb.Equals(TextSearchAbi) Then
                If e.KeyCode.Equals(Keys.Enter) Then
                    index = ListAbi.FindString(tb.Text)
                    If index <> -1 Then
                        ListAbi.SetSelected(index, True)
                    End If
                    tb.Clear()
                    e.Handled = True
                End If
            End If
        ElseIf TypeOf sender Is ListBox Then
            Dim lb = DirectCast(sender, ListBox)
            If lb.Equals(ListAbi) Then
                If e.KeyCode.Equals(Keys.Enter) Then
                    index = lb.FindString(TextSearchAbi.Text)
                    If index <> -1 Then
                        lb.SetSelected(index, True)
                    End If
                    TextSearchAbi.Clear()
                    e.Handled = True
                ElseIf e.KeyCode.Equals(Keys.Back) Then
                    If TextSearchAbi.Text.Length > 0 Then
                        TextSearchAbi.Text = TextSearchCW.Text.Substring(0, TextSearchAbi.Text.Length - 1)
                    End If
                Else
                    TextSearchAbi.Text = TextSearchAbi.Text + Convert.ToChar(e.KeyCode)
                End If
            End If
        End If
    End Sub

Open in new window

ee.JPG
0
Comment
Question by:PeterBaileyUk
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:louisfr
ID: 41774522
You could call the OnKeyUpXXX methods and pass the arguments you want.
0
 

Author Comment

by:PeterBaileyUk
ID: 41774618
how do i pass an 'enter' to the method. that for sure would do it.
0
 
LVL 11

Accepted Solution

by:
louisfr earned 500 total points
ID: 41774624
OnKeyUpCW(TextSearchCW, New KeyEventArgs(Keys.Enter))

Open in new window

0
 

Author Closing Comment

by:PeterBaileyUk
ID: 41775888
thank you
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now