[Csharp] /// <summary> /// Add a row number to the DataGridView /// </summary> /// <param name = "dgv"> DataGridView Control ID </param> public static void AddRowIndex (this DataGridView dgv) {dgv. rowPostPaint + = delegate (object sender, DataGridViewRowPostPaintEventArgs e) {SolidBrush B = new SolidBrush (dgv. rowHeadersDefaultCellStyle. foreColor); e. graphics. drawString (e. rowIndex + 1 ). toString (), dgv. defaultCellStyle. font, B, e. rowBounds. location. X + 10, e. rowBounds. location. Y + 4 );};} /// <summary> /// select all for the DataGridView /// </summary> /// <param name = "dgv"> DataGridView Control ID </param> /// <param name = "columnIndex"> sequence number of all columns </param> public static void AddFullSelect (this DataGridView dgdgv, int columnIndex) {if (dgv. rows. count <1) {return;} CheckBox ckBox = new CheckBox (); Rectangle rect = dgv. getCellDisplayRectangle (1,-1, true); ckBox. size = new Size (dgv. columns [1]. width-12, 12); // size Point point = new Point (rect. X + 10, rect. Y + 3); // The position ckBox. location = point; ckBox. checkedChanged + = delegate (object sender, EventArgs e) {for (int I = 0; I <dgv. rows. count; I ++) {dgv. rows [I]. cells [columnIndex]. value = (CheckBox) sender ). checked;} dgv. endEdit () ;}; dgv. controls. add (ckBox );}