Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB.net listbox. make all searches occur

Posted on 2016-08-28
4
Medium Priority
?
60 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 12

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 12

Accepted Solution

by:
louisfr earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

810 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