Solved

mimic enter on vb.net form

Posted on 2016-08-26
2
60 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 500 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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 Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

689 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