private void DgvCamposVisibles_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { DgvCamposVisibles.PostEditor(); if (DgvCamposVisibles.FocusedColumn.FieldName == "Tamaño") { String v = DgvCamposVisibles.GetRowCellValue(DgvCamposVisibles.FocusedRowHandle, DgvCamposVisibles.Columns[2]).ToString(); if (String.IsNullOrEmpty(v)) { v = "0"; } int t = Convert.ToInt32(v); if (t <= 0) { // XtraMessageBox.Show("El tamaño debe ser mayor que 0", GLReferences.Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information); dtGrillaCamposVisibles.Rows[DgvCamposVisibles.FocusedRowHandle][2].ToString(); DgvCamposVisibles.SetRowCellValue(DgvCamposVisibles.FocusedRowHandle, DgvCamposVisibles.Columns[2], "100"); } } }
private void GvCampos_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { DgvCampos.PostEditor(); bool estado = (bool)(DgvCampos.GetRowCellValue(DgvCampos.FocusedRowHandle, DgvCampos.Columns["Visible"])); if (DgvCampos.FocusedColumn.FieldName == "Visible") { if (vCampoId != null) { if (estado == false) { String cmpo = DgvCampos.GetRowCellValue(DgvCampos.FocusedRowHandle, DgvCampos.Columns["Campo"]).ToString(); String indx = Convert.ToString(dtGrillaCamposVisibles.Rows.Count); dtGrillaCamposVisibles.Rows.Add(new String[] { cmpo, cmpo, "100", indx }); } else { String cmpo = DgvCampos.GetRowCellValue(DgvCampos.FocusedRowHandle, DgvCampos.Columns["Campo"]).ToString(); for (int i = 0; i < DgvCamposVisibles.RowCount; i++) { if (DgvCamposVisibles.GetRowCellDisplayText(i, "CampoId") == cmpo) { dtGrillaCamposVisibles.Rows.RemoveAt(i); for (int j = 0; j < DgvCamposVisibles.RowCount; j++) { if (Convert.ToInt32(dtGrillaCamposVisibles.Rows[j][3]) > dtGrillaCamposVisibles.Rows.Count - 1) { dtGrillaCamposVisibles.Rows[j][3] = Convert.ToString(dtGrillaCamposVisibles.Rows.Count - 1); } } break; } } } } else { if (estado == false) { String cmpo = DgvCampos.GetRowCellValue(DgvCampos.FocusedRowHandle, DgvCampos.Columns["Campo"]).ToString(); String indx = Convert.ToString(dtGrillaCamposVisibles.Rows.Count); dtGrillaCamposVisibles.Rows.Add(new String[] { cmpo, cmpo, "100", indx }); } else { String cmpo = DgvCampos.GetRowCellValue(DgvCampos.FocusedRowHandle, DgvCampos.Columns["Campo"]).ToString(); for (int i = 0; i < DgvCamposVisibles.RowCount; i++) { if (DgvCamposVisibles.GetRowCellDisplayText(i, "CampoId") == cmpo) { dtGrillaCamposVisibles.Rows.RemoveAt(i); for (int j = 0; j < DgvCamposVisibles.RowCount; j++) { if (Convert.ToInt32(dtGrillaCamposVisibles.Rows[j][3]) > dtGrillaCamposVisibles.Rows.Count - 1) { dtGrillaCamposVisibles.Rows[j][3] = Convert.ToString(dtGrillaCamposVisibles.Rows.Count - 1); } } break; } } } } } if (DgvCampos.FocusedColumn.FieldName == "Agregar" && (bool)DgvCampos.GetDataRow(DgvCampos.FocusedRowHandle)[DgvCampos.FocusedColumn.FieldName]) { DgvCampos.SetRowCellValue(DgvCampos.FocusedRowHandle, DgvCampos.Columns["Visible"], false); if (vCampoId != null || dtGrillaCamposVisibles.Rows.Count != 0) { String cmpo = DgvCampos.GetRowCellValue(DgvCampos.FocusedRowHandle, DgvCampos.Columns["Campo"]).ToString(); for (int i = 0; i < DgvCamposVisibles.RowCount; i++) { if (DgvCamposVisibles.GetRowCellDisplayText(i, "CampoId") == cmpo) { dtGrillaCamposVisibles.Rows.RemoveAt(i); for (int j = 0; j < DgvCamposVisibles.RowCount; j++) { if (Convert.ToInt32(dtGrillaCamposVisibles.Rows[j][3]) > dtGrillaCamposVisibles.Rows.Count - 1) { dtGrillaCamposVisibles.Rows[j][3] = Convert.ToString(dtGrillaCamposVisibles.Rows.Count - 1); } } break; } } } } }