0

我有一个包含 3 列的 datagridview,我想要 datagridview 中的第一列没有焦点,请任何人都可以帮助我 plzzz 我该怎么做?

4

1 回答 1

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);
        }
    }
}
于 2012-12-13T15:52:34.460 回答