using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace SomeNamespace
{
/// <summary>
/// A column that presents it's control to the user on one click instead of the usual two.
/// </summary>
public class CustomDataGridCell: DataGridViewTextBoxCell
{
/// <summary>
/// Constructor
/// </summary>
public CustomDataGridCell()
{
}
/// <summary>
/// An override of mouse click to show the editing control to the user earlier than usual.
/// </summary>
/// <remarks>
/// "Borrowed" from the .NET Framework by looking at the DataGridViewTextBoxCell with Reflector.
/// 1 condition has also been removed.
/// </remarks>
/// <param name="e"></param>
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);
}
}
}
}
}
}