Link to home
Start Free TrialLog in
Avatar of rwheeler23
rwheeler23Flag 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;
        }
ASKER CERTIFIED SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial