private void DgDr_KeyDown(object sender, KeyEventArgs e) { try { if (DgDr.CurrentRow != null) { int GId = DgDr.CurrentRow.Cells["ColParticularDrGId"].EditedFormattedValue.ToString().IntParse(); int AId = DgDr.CurrentRow.Cells["ColParticularDrAId"].EditedFormattedValue.ToString().IntParse(); if (e.KeyData == Keys.Enter) { e.SuppressKeyPress = true; e.Handled = true; //if (AId != 0) //{ // clsGeneral.Accounting_Main.OpMonthlySummary(AId, dateTimePicker1.Value, this); //} //else //{ // clsGeneral.Accounting_Main.OpgroupSummary(GId, dateTimePicker1.Value, this); //} } if (e.KeyData == Keys.Space) { e.SuppressKeyPress = true; e.Handled = true; DataGridViewCellStyle CompStyle1 = new DataGridViewCellStyle(); CompStyle1.ForeColor = Color.Red; CompStyle1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); DataGridViewCellStyle CompStyle2 = new DataGridViewCellStyle(); CompStyle2.ForeColor = Color.Black; CompStyle2.Font = new System.Drawing.Font("Tahoma", 9.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); if (DgDr.CurrentRow.DefaultCellStyle.ToString() == CompStyle1.ToString() || DgDr.CurrentRow.DefaultCellStyle.ToString() == CompStyle2.ToString()) { int Index = DgDr.CurrentRow.Index; for (int i = Index + 1; i < DgDr.Rows.Count; i++) { int GCId = DgDr.Rows[i].Cells["ColParticularDrGId"].EditedFormattedValue.ToString().IntParse(); if (GId == GCId) { DgDr.Rows[i].Visible = !DgDr.Rows[i].Visible; } } DgDr.Refresh(); } } } } catch (Exception Erp) { clsGeneral.ShowErrMsg(Erp.Message); } }