using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Drawing; namespace SomeNamespace { /// /// A column that presents it's control to the user on one click instead of the usual two. /// public class CustomDataGridCell: DataGridViewTextBoxCell { /// /// Constructor /// public CustomDataGridCell() { } /// /// An override of mouse click to show the editing control to the user earlier than usual. /// /// /// "Borrowed" from the .NET Framework by looking at the DataGridViewTextBoxCell with Reflector. /// 1 condition has also been removed. /// /// protected override void OnMouseClick(DataGridViewCellMouseEventArgs e) { base.OnMouseClick(e); if (base.DataGridView != null) { Point point1 = base.DataGridView.CurrentCellAddress; if (((point1.X == e.ColumnIndex) && (point1.Y == e.RowIndex)) && (e.Button == MouseButtons.Left)) { if (base.DataGridView.EditMode != DataGridViewEditMode.EditProgrammatically) { base.DataGridView.BeginEdit(true); } } } } } }