Solved

Modify keyword search code so enter key performs click

Posted on 2014-03-29
3
146 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
[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
3 Comments
 
LVL 63

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 63

Expert Comment

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

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
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…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

729 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