?
Solved

mimic enter on vb.net form

Posted on 2016-08-26
2
Medium Priority
?
62 Views
Last Modified: 2016-08-27
I have a form that uses ITSaiges code to find search term in a grid. that all works fine.

I have added some code in the first column search textbox keypress event that sends the value to the other column search boxes if the option bottom right is selected.

What I cannot find out is how to make the other search textboxes mimic an enter keypress when I press enter in the first column textbox.

so here i typed '1067' and if i then press enter the search term is found in the first column, I would like it to do the searches in the other columns. the individual columns work ie if i go to the next column and press enter in the text box it would find 1067.
    Private Sub TextSearchStrDescCW_KeyUp(sender As Object, e As KeyEventArgs) Handles TextSearchStrDescCW.KeyUp
        Dim tb = DirectCast(sender, TextBox)
        If tb.Equals(TextSearchStrDescCW) Then
            If e.KeyCode.Equals(Keys.Enter) Then
                DataGridViewStringsCW.SearchAndSelect(tb.Text, CBSearchDescCW.SelectedItem, True)
                tb.Clear()
                e.Handled = True
            End If
        End If

        If OPShtDescIndependant.Checked = True Then

        Else
            TextSearchStrDescAbi.Text = TextSearchStrDescCW.Text
            TextSearchStrDescCap.Text = TextSearchStrDescCW.Text
            TextSearchStrDescGlass.Text = TextSearchStrDescCW.Text
            TextSearchStrDescTvi.Text = TextSearchStrDescCW.Text



        End If
    End Sub

Open in new window



    Private Sub TextSearchStrDescCW_KeyUp(sender As Object, e As KeyEventArgs) Handles TextSearchStrDescCW.KeyUp
        Dim tb = DirectCast(sender, TextBox)
        If tb.Equals(TextSearchStrDescCW) Then
            If e.KeyCode.Equals(Keys.Enter) Then
                DataGridViewStringsCW.SearchAndSelect(tb.Text, CBSearchDescCW.SelectedItem, True)
                tb.Clear()
                e.Handled = True
            End If
        End If

        If OPShtDescIndependant.Checked = True Then

        Else
            TextSearchStrDescAbi.Text = TextSearchStrDescCW.Text
            TextSearchStrDescCap.Text = TextSearchStrDescCW.Text
            TextSearchStrDescGlass.Text = TextSearchStrDescCW.Text
            TextSearchStrDescTvi.Text = TextSearchStrDescCW.Text



        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 Comments
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 2000 total points
ID: 41772683
i dont understand the actions you want...

if user presses <enter> when typing in any of the search boxes,  you want all searches to occur ?

if so, then a single key handler may suffice

    Private Sub TextSearchStrDescCW_KeyUp(sender As Object, e As KeyEventArgs) Handles TextSearchStrDescCW.KeyUp
        Dim tb = DirectCast(sender, TextBox)
        dim tbMasterValue as string = tb.Text
        If OPShtDescIndependant.Checked = True Then
            'do nothing
        Else
            'copy active text to all searches
            TextSearchStrDescCW.Text = tbMasterValue
            TextSearchStrDescAbi.Text = tbMasterValue
            TextSearchStrDescCap.Text = tbMasterValue
            TextSearchStrDescGlass.Text = tbMasterValue
            TextSearchStrDescTvi.Text = tbMasterValue
        End If

            If e.KeyCode.Equals(Keys.Enter) Then
                DataGridViewStringsCW.SearchAndSelect(tb.Text, CBSearchDescCW.SelectedItem, True)
               DataGridViewStringsAbi.SearchAndSelect(tb.Text, CBSearchDescAbi.SelectedItem, True)
                DataGridViewStringsCap.SearchAndSelect(tb.Text, CBSearchDescCap.SelectedItem, True)
                DataGridViewStringsGlass.SearchAndSelect(tb.Text, CBSearchDescGlass.SelectedItem, True)
                DataGridViewStringsTvi.SearchAndSelect(tb.Text, CBSearchDescTvi.SelectedItem, True)
                tb.Clear()
                e.Handled = True
            End If

            

    End Sub

Open in new window

0
 

Author Closing Comment

by:PeterBaileyUk
ID: 41772712
worked a treat sorry its hard saying what I wanted. anyway Thank you
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

764 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