csharp net
csharp net

Reputation: 33

How to skip a column in datagridview when the tab key is pressed

Is there a way to skip certain columns when the tab key/arrow key is pressed?

Suppose I have three columns (col1,col2,col3). Say I was on col1, I would want to skip col2 when the tab key is pressed.

How can I do this?

Upvotes: 2

Views: 2665

Answers (1)

Angus Chung
Angus Chung

Reputation: 1587

You can do it in CellEnter event.

Try this:

    private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
    {           
        if (dataGridView1.Columns[e.ColumnIndex].Name == "col2")
        {
            SendKeys.Send("{TAB}");
        } 
    }

Upvotes: 7

Related Questions