我有一个包含3列的datagridview,我希望datagridview中的第一列没有焦点,PLZ可以帮助我plzzz如何做到这一点。?
答案 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);
}
}
}