yonan2236
yonan2236

Reputation: 13659

How to prevent in highlighting the next row in datagridview every time you hit enter key?

I'm trying it in C# language.. I don't know how to accomplish it. Please help me guys...

Thanks...

Upvotes: 3

Views: 1276

Answers (2)

yonan2236
yonan2236

Reputation: 13659

Add an event to the DataGridView control.

private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyData == Keys.Enter)
    {
        e.Handled = true;
    }
}

This event bypasses the undesired behavior of the DataGridView when Enter key is being pressed.

Upvotes: 5

SwDevMan81
SwDevMan81

Reputation: 50028

You can set the SelectionMode to CellSelect and it will only select the cell.

Upvotes: 0

Related Questions