如何在C#.net win apps中将datagridview列为Tabstop property = false的一列?

时间:2012-12-13 08:50:03

标签: datagridview

我有一个包含3列的datagridview,我希望datagridview中的第一列没有焦点,PLZ可以帮助我plzzz如何做到这一点。?

1 个答案:

答案 0 :(得分:0)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DataGridViewValidation.Controls
{
    public class DataGridViewTabColumnFalse : DataGridView
    {
        protected override bool ProcessDataGridViewKey(KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Tab)
            {
                if (CurrentCell.ColumnIndex == 0)
                {
                    e.SuppressKeyPress = true;
                    return true;
                }
            }
            return base.ProcessDataGridViewKey(e);
        }


        protected override bool ProcessDialogKey(Keys keyData)
        {
            if (keyData == Keys.Tab)
            {
                if (CurrentCell.ColumnIndex == 0)
                {
                    return true;
                }
            }

            return base.ProcessDialogKey(keyData);
        }
    }
}