Solved

mimic enter on vb.net form

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 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

16 Experts available now in Live!

Get 1:1 Help Now