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 136491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:57:25+00:00 2026-05-11T06:57:25+00:00

I have a working WinForm that handles the search functionality in my customer database.

  • 0

I have a working WinForm that handles the search functionality in my customer database. It contains the following controls:

  • A textBox where you type your search string (A)
  • A ‘search’ button (B)
  • A DataGridView (C) that returns the result of the search
  • An ‘OK’ button (D) and a ‘Cancel’ button (E)

What I am trying to accieve next is this:

  1. When A is active the AcceptButton (enter) should be linked to B
  2. When B or enter is pressed C should become active
  3. When C is active the AcceptButton should be linked to D

I realise this is a somewhat big question so don’t hesitate to answer just one of the bullet marks if you know the answer.

EDIT: I have solved the implementation of requirement 1 and 3 above, but I am still looking for an answer to the second one. To clarify, when the search is initiated (meaning i have pressed enter on the keyboard or the search button with the mouse) I want focus to shift to the first line in the DataGridView.

  • 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. 2026-05-11T06:57:25+00:00Added an answer on May 11, 2026 at 6:57 am

    When you get the text changed event for textBox set the AcceptButton to be ‘Search’:

        private void textBox1_TextChanged(object sender, EventArgs e)     {         this.AcceptButton = SearchButton;     } 

    There will probably want to be more code in here, checking the length of the string etc.

    Then once you’ve done the search and filled in the DataGridView you can then set the AcceptButton to be ‘OK’.

        private void dataGridView1_DataMemberChanged(object sender, EventArgs e)     {         this.AcceptButton = OKButton;     } 

    Though you probably wouldn’t want to use this event.

    ‘Cancel’ is always the CancelButton.

    EDIT: OK for part 2 you want the following code:

        private void SearchButton_Click(object sender, EventArgs e)     {         dataGridView1.Focus();     } 

    This will make it active as soon as the search button is pressed, but you probably want to do it when the DataGridView has been populated – just in case the search returned no results.

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

Sidebar

Ask A Question

Stats

  • Questions 92k
  • Answers 92k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Both Oracle and PostgreSQL support what's called sequences and the… May 11, 2026 at 6:26 pm
  • Editorial Team
    Editorial Team added an answer And App_Themes was never any good anyway. It's limited. Just… May 11, 2026 at 6:26 pm
  • Editorial Team
    Editorial Team added an answer A namespace alias perhaps: using Forms = System.Windows.Forms; The "using… May 11, 2026 at 6:26 pm

Related Questions

In VB.NET, I have a Combobox on a WinForm form. The form allows the
I am working on a Sometimes Connected CRUD application that will be primarily used
I have seen this question: Are there any decent UI components for touch screen
I have a server application (singleton, simple .NET console application) that talks to a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.