Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8915933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:06:15+00:00 2026-06-15T05:06:15+00:00

I am new to c# , i have one TextBox and one gridview when

  • 0

I am new to c# , i have one TextBox and one gridview when user type something in Textbox to search, the gridview is filled succesfully when clicked on search button.
But my concern is instaed of search button use ENTER KEY TO search data in gridview.

private void textBox3_TextChanged(object sender, KeyPressEventArgs e1, EventArgs e) 
{
    if (e1.KeyCode == Keys.Enter) 
    { 
       string sql = "[DocEntry],[JobCardNo],[ITEMNAME],[OD] ,[PlanQty],
                      [FinalInspectionRemarks] ,[OrderDate] ,[Division]
                          WHERE JobCardNo ='" + textBox3.Text.ToString() + "'";  
       SqlDataAdapter da = new SqlDataAdapter(sql, objConn1); DataSet ds = new DataSet(); 
       objConn1.Open(); 
       da.Fill(ds, "ProductionInventoryReport"); 
       dataGridView1.DataSource = ds; //dataGridView1.DataBind();  
       dataGridView1.DataMember = "ProductionInventoryReport"; 
       objConn1.Close(); e1.Handled = true; 
     } 
 } 

I have tried this but not working

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:06:16+00:00Added an answer on June 15, 2026 at 5:06 am

    Instead of TextChanged event do it on KeyPress event.

    First attach the event to the textbox, either in designer or in code like:

    textBox3.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox3_KeyPress);
    

    Then

     private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
            {
                if (e.KeyChar == (char)13) // enter key pressed
                { 
                 //searchMethod(); 
                }
            }
    

    Its better if you extract the search code to a separate method and then call the same method against your search button and KeyPress event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a new one I have never seen before. I have a gridview
I have a form with a textbox and a add button. The user can
I have one textbox and one button. The Button Command should change the property
I have a form with one textbox and one button. Here I need to
I have a simple form with just one textbox and one submit button. The
i have listview one button( default content == Add) and 1 textbox. On list
i have one doubt,i have created new project in eclipse with android 2.3.1 and
I have one static Semaphore instance. Semaphore semaphore = new Semaphore(1); Now I have
I have one variable var1='common_location/specific_location_1/common_filename_text' now I have to get a new variable var2='common_location/specific_location_2/common_filename_text'.
I have my new macbook air. I have created one test application. now i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.