Avatar of rwheeler23
rwheeler23
Flag for United States of America asked on

C# Lookup window to return using Enter/Return

I have a C# lookup window that I wanted to add hitting the Enter/Return key to return the value. As soon as I did that it killed double click. As soon as I move the mouse pointer the lookup window exits.  How do I get this to work so both double-click and Enter return the value?

        private void dgvBatches_DoubleClick(object sender, EventArgs e)
        {
            int currentRow;

            currentRow = dgvBatches.CurrentCell.RowIndex;
            dgvBatches.CurrentCell = dgvBatches[0, currentRow];
            CellValue = dgvBatches.CurrentCell.Value.ToString();

            DialogResult = DialogResult.OK;

            return;
        }

        private void dgvBatches_Enter(object sender, EventArgs e)
        {
            int currentRow;

            currentRow = dgvBatches.CurrentCell.RowIndex;
            dgvBatches.CurrentCell = dgvBatches[0, currentRow];
            CellValue = dgvBatches.CurrentCell.Value.ToString();

            DialogResult = DialogResult.OK;

            return;
        }
C#

Avatar of undefined
Last Comment
it_saige

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
it_saige

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck