Solved

mimic enter on vb.net form

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now