Solved

Modify keyword search code so enter key performs click

Posted on 2014-03-29
3
144 Views
Last Modified: 2014-04-03
Software vb.net: Windows application.

Private Sub TextBoxSearch_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs)

        If (e.KeyCode = Keys.Enter) Then
            FilterProducts()
        End If

    End Sub

    Private Sub FilterProducts()

        If (TextBoxSearchC.Text = "") And TextBoxSearchP.Text = "" Then 'And TextBoxSearchL.Text = "" And TextBoxSearchF.Text = "" And TextBoxSearchT.Text = "" And TextBoxSearchB.Text = "" And TextBoxSearchCM.Text = "" Then
            MyTableBindingSource.RemoveFilter()
        Else
             MyTableBindingSource.Filter = "CompanyName like '" + TextBoxSearchC.Text + "%'" + "and PlanNumber like '" + TextBoxSearchP.Text + "%'" '+ "and Location like '" + TextBoxSearchL.Text + "%'" + "and FixtureType like '" + TextBoxSearchF.Text + "%'" + "and TrimType like '" + TextBoxSearchT.Text + "%'" + "and NumberBaths like '" + TextBoxSearchB.Text + "%'" + "and Comments like '" + TextBoxSearchCM.Text + "%'"
        End If

    End Sub

    Private Sub ButtonSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSearch.Click

        FilterProducts()
        Me.TextBoxSearchC.Clear()
        Me.TextBoxSearchP.Clear()

    End Sub

Open in new window

0
Comment
Question by:dave_sky
  • 2
3 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39964427
Hi dave_sky;

Do you wish to invoke the ButtonSearch_Click event when you press the Enter key while in the TextBoxSearch? If so then this should do it.

If (e.KeyCode = Keys.Enter) Then
    ButtonSearch.PerformClick( )
End If

Open in new window

0
 

Author Closing Comment

by:dave_sky
ID: 39975863
Thanks!
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 39975917
Not a problem, glad to help.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 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