Solved

mimic enter on vb.net form

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

839 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