We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date


Here is what I wound up with. I think it is a simpler approach. public class SingleClickDataGrid : DataGrid { public SingleClickDataGrid() { this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.GridMouseDown); } public void GridMouseDown(object sender, MouseEventArgs e) { System.Windows.Forms.DataGrid.HitTestInfo hi; // let's see where we clicked... hi = HitTest(e.X,e.Y); // If the user did not click on a cell, we don't care... // we'll just pass on to the base class if(hi.Type == System.Windows.Forms.DataGrid.HitTestType.Cell) { // Get the TableStyles collection DataGridTableStyle dgt = TableStyles[0]; // Get the ColumnStyle for the selected column DataGridColumnStyle myCol = dgt.GridColumnStyles[hi.Column]; // Is this a check box column? // if not, we'll let the base class handle it if(myCol.GetType() == typeof(DataGridBoolColumn)) { // First part of the magic... select the row, so that the edit can happen Select(hi.Row); // Call the grid table style to start and end the edit dgt.BeginEdit(myCol,hi.Row); dgt.EndEdit(myCol,hi.Row,true); } } } }

Live Chat Icon For mobile
Up arrow icon