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

  • SEARCH
  • Home
  • 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 6240439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:34:16+00:00 2026-05-24T11:34:16+00:00

This is the real challenge I brings here for you. Solve it if you

  • 0

This is the real challenge I brings here for you. Solve it if you can.

The Enter Key On Datagridview Is it good Idea? Or Is it possible for any body here to work it as per following condition?.

If not than Datagridview Control is useless on enter key press.

I have Following Custom DGV:

public class MyDataGridView : DataGridView
    {
        protected override bool ProcessDialogKey(Keys keyData)
        {
            Keys key = (keyData & Keys.KeyCode);
            if (key == Keys.Enter)
            {
                Tab(keyData);
                return true;
            }
            return base.ProcessDialogKey(keyData);
        }
        protected override bool ProcessDataGridViewKey(KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                Tab(e.KeyData);
                return true;
            }
            return base.ProcessDataGridViewKey(e);
        }
        private void Tab(Keys KeyData)
        {
            Point cca = CurrentCellAddress;
            bool Forward = ((KeyData & Keys.Shift) != Keys.Shift);
            if (Forward)
                if (cca.Y == Rows.Count - 1)            // last row?
                    if (cca.X == Columns.Count - 1)     // last column?
                        ToNextControl(Forward);
                    else
                        ProcessTabKey(KeyData);
                else
                    ProcessTabKey(KeyData);
            else
                if (cca.Y == 0)         // first row?
                    if (cca.X == 0)     // first column?
                        ToNextControl(Forward);
                    else
                        ProcessTabKey(KeyData);
                else
                    ProcessTabKey(KeyData);
        }

        /// <summary>
        /// Go to the next control, forward or backword. This does not support
        /// wrapping from the first to the last or the last to the first.
        /// </summary>
        /// <param name="Forward">Whether to go forward</param>
        private void ToNextControl(bool Forward)
        {
            Control c = Parent.GetNextControl(this, Forward);
            while (c != null && !c.TabStop) // get next control that is a tabstop
                c = Parent.GetNextControl(c, Forward);
            if (c != null)
                c.Select();
        }
    }

The Same work well on normal it’s allow focus on next control at enter keypress but it’s not work if you set AllowUserToAddRows=false on databound mode. The exact problem creates when you edit last column’s cell value and press enter it’s not allow to set focus on next control.

How to overcome from this?. how to solve the issue?

  • 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-05-24T11:34:20+00:00Added an answer on May 24, 2026 at 11:34 am

    I found a solution that should work for you by adding a focus event on the current control. I think this is what you want, but couldn’t really understand your question. Let me know if it is something different. It works for AllowUserToAddRows = false or true.

     private void ToNextControl(bool Forward)
        {
            Control c = Parent.GetNextControl(this, Forward);         
            while (c != null && !c.TabStop) // get next control that is a tabstop
                c = Parent.GetNextControl(c, Forward);
            if (c != null)
            {
                //c.Select(); // Not needed for it to work
                c.Focus(); // force it to focus
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So this should be a real easy question but I can't seem to find
This is a simplified task which I have to solve in real project. In
Here's my wild and whacky psuedo-code. Anyone know how to make this real? Background:
I'm facing a design challenge that I just can't seem to solve in a
In a .f file there is code that does this: real Bob, avar ...
This is a real newbie question. I have simple app that selects a picture
Note: this is not real information: $ ssh-keygen -t rsa -C "tekkub@gmail.com" Generating public/private
This one is a real head scratcher for me... var matches = Regex.Matches(<p>test something<script
This is not a real bug BUT for sure it is not what you
If this is not a real question then feel free to close ;)

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.