Solved

VB.net listbox. make all searches occur

Posted on 2016-08-28
4
53 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 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