简体   繁体   中英

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?

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}");
        } 
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM