public override void InvokeAction(object sender, EventArgs e) { GridControlBase grid = ActiveGrid; if (grid != null) { GridRangeInfoList ranges = grid.Model.Selections.Ranges.GetColRanges(GridRangeInfoType.Cols); if (ranges.Count == 0) { return; } grid.Model.CommandStack.BeginTrans("Remove Columns"); foreach (GridRangeInfo range in ranges) { grid.Model.Cols.RemoveRange(range.Left, range.Right); } grid.Model.CommandStack.CommitTrans(); } }
private void selExport_Click(object sender, RoutedEventArgs e) { GridRangeInfoList rangeList = gc.Model.SelectedRanges; if (rangeList.Count > 0) { GridRangeInfo range = rangeList[0]; gc.Model.ExportToCSV(range, @"Sample.csv"); try { System.Diagnostics.Process.Start("Sample.csv"); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } else { MessageBox.Show("Select the range first"); } }
void BackgroundColorPicker_ColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var color = this.BackgroundColorPicker.Color; GridControl ActiveGrid = ((tControl.SelectedItem as TabItem).Content as ScrollViewer).Content as GridControl; if (ActiveGrid != null) { GridRangeInfoList rangeList = ActiveGrid.Model.SelectedRanges; foreach (GridRangeInfo range in rangeList) { for (int row = range.Top; row <= range.Bottom; row++) { for (int col = range.Left; col <= range.Right; col++) { ActiveGrid.Model[row, col].Background = new SolidColorBrush(color); } } ActiveGrid.InvalidateCell(range); } ActiveGrid.InvalidateVisual(); } this.BGColorSplitButton.IsDropDownOpen = false; }
private void ForegroundColorPicker_SelectedBrushChanged(object sender, SelectedBrushChangedEventArgs e) { var color = this.ForegroundColorPicker.Color; SampleGridControl ActiveGrid = ((Tab1.SelectedItem as TabItem).Content as ScrollViewer).Content as SampleGridControl; if (ActiveGrid != null) { GridRangeInfoList rangeList = ActiveGrid.Model.SelectedRanges; foreach (GridRangeInfo range in rangeList) { for (int row = range.Top; row <= range.Bottom; row++) { for (int col = range.Left; col <= range.Right; col++) { ActiveGrid.Model[row, col].Foreground = new SolidColorBrush(color); } } ActiveGrid.InvalidateCell(range); } ActiveGrid.InvalidateVisual(); } this.ForeColorSplitButton.IsDropDownOpen = false; }
/// <summary> /// After rows were scrolled. /// </summary> /// <param name="e"></param> protected override void OnTopRowChanged(GridRowColIndexChangedEventArgs e) { base.OnTopRowChanged(e); //inTopRowChanging = false; if (centerTextInVisibleCellPart && e.Success) { int rowIndex1 = TopRowIndex - 1; bool visRow1 = false;//ViewLayout.IsRowVisible(rowIndex1) && savedTopVisible; int rowIndex2 = savedBottomRow; bool visRow2 = !ViewLayout.HasPartialVisibleRows; int clientCols = ViewLayout.VisibleCols; if (!visRow1 || !visRow2) { GridRangeInfoList ranges = new GridRangeInfoList(); for (int n = 0; n < clientCols; n++) { int colIndex = GetCol(n); GridRangeInfo mergeRange; if (!visRow1) { int r = Math.Max(rowIndex1, savedTopRow); if (Model.MergeCells.Find(GridMergeCellDirection.RowsInColumn, r, colIndex, out mergeRange) && !ranges.Contains(mergeRange)) { if (mergeRange.Bottom >= TopRowIndex) { // found a merged range that is only partially visible and this // needs to be fully repainted (since we do want to center text // within the visible boundaries of the cell only and not scroll // centered text out of view). Update(); RefreshRange(mergeRange); ranges.Add(mergeRange); } } } if (!visRow2) { if (Model.MergeCells.Find(GridMergeCellDirection.RowsInColumn, rowIndex2, colIndex, out mergeRange) && !ranges.Contains(mergeRange)) { if (mergeRange.Top <= rowIndex2) { // found a merged range that is only partially visible and this // needs to be fully repainted (since we do want to center text // within the visible boundaries of the cell only and not scroll // centered text out of view). Update(); RefreshRange(mergeRange); } } } } } } }
private void cmdInscribir_Click(object sender, EventArgs e) { if ((!txtNroDocumento.Text.Equals("")) && (!txtProveedor.Text.Equals("")) && (!txtContacto.Text.Equals("")) && (!lblIDCargo.Text.Equals("0"))) { try { WSLicitaciones.WSLicitaciones WSLic = new WSLicitaciones.WSLicitaciones(); WSLic.Url = mdlGenerales.DireccionWS + "FazServices/WSLicitaciones.asmx"; DataSet Devuelve = new DataSet(); String ndoc = ""; String tipodoc = ""; GridRangeInfoList range = GGCPersLiq.TableControl.Selections.GetSelectedRows(true, true); foreach (GridRangeInfo info in range) { Element el = this.GGCPersLiq.TableModel.GetDisplayElementAt(info.Top); ndoc = el.GetRecord().GetValue("NDoc").ToString(); tipodoc = el.GetRecord().GetValue("idtipodoc").ToString(); } Devuelve = WSLic.InscribePersonalOs(mdlGenerales.Conexion, lblIDooss.Text, lblIDSelOs.Text.ToString(), txtNroDocumento.Text.ToString(), txtContacto.Text.ToString(), mdlGenerales.STRUsuario, ndoc, tipodoc, lblIDCargo.Text.ToString(), lblDireccion.Text.ToString(), txtProveedor.Text.ToString()); DataTable DTSuccess = new DataTable(); DTSuccess = Devuelve.Tables[0]; Int32 codigo = 0; String mensaje = ""; foreach (DataRow row in DTSuccess.Rows) { codigo = Convert.ToInt32(row[0].ToString()); mensaje = row[1].ToString(); } if (codigo != 0) { MessageBoxAdv.Show(mensaje, "Informacion" + codigo, MessageBoxButtons.OK, MessageBoxIcon.Information); txtNroDocumento.Focus(); } else { MessageBoxAdv.Show(mensaje, "Error" + codigo, MessageBoxButtons.OK, MessageBoxIcon.Error); } lblIDSelOs.Text = "0"; lblCorrelativo.Text = codigo.ToString(); lblIDooss.Text = codigo.ToString(); txtCargo.Text = ""; lblIDCargo.Text = "0"; CargaGrid(); CargaGridOs(); } catch (Exception exx) { MessageBoxAdv.Show("Asegurese de completar todos los campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { txtCargo.Text = ""; } } else { MessageBoxAdv.Show("Asegurese de completar todos los campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtCargo.Text = ""; } //Setear }
/// <summary> /// **************** TODO: COMPLETE DOCUMENTATION ***************** /// /// When the "Remove Entry" button is clicked, remove the selected employee and customer entries /// along with the related schedule and attendance entries respectively, from the database and from the /// DataSet. Update the grid to the reflect these changes. /// </summary> private void removeButton_Click(object sender, EventArgs e) { try { GridRangeInfoList range = databaseGrid.TableModel.Selections.GetSelectedRows(true, true); foreach (GridRangeInfo info in range) { Element element = databaseGrid.TableModel.GetDisplayElementAt(info.Top); GridNestedTable gnt = element as GridNestedTable; GridNestedTable gnt1 = gnt; while (gnt1 != null && gnt1.ChildTable != null) { gnt = gnt1; gnt1 = gnt.ChildTable.ParentTable.CurrentElement as GridNestedTable; } DataRowView drv = gnt.ChildTable.ParentTable.CurrentElement.GetData() as DataRowView; string table = gnt.ChildTable.ParentTable.CurrentElement.GetRecord().ParentChildTable.Name; if (table == "Employees") { DatabaseWorker.RemoveEmployee(Convert.ToInt32(drv[0])); Record record = gnt.ChildTable.ParentTable.CurrentElement.GetRecord(); int index = databaseGrid.GetTable("Employees").UnsortedRecords.IndexOf(record); databaseGrid.GetTable("Employee Schedule").UnsortedRecords[index].Delete(); record.Delete(); database.Tables["Employees"].Rows[index].Delete(); database.Tables["Employee Schedule"].Rows[index].Delete(); database.AcceptChanges(); } else if (table == "Customers") { DatabaseWorker.RemoveCustomer(Convert.ToInt32(drv[0])); Record record = gnt.ChildTable.ParentTable.CurrentElement.GetRecord(); int index = databaseGrid.GetTable("Customers").UnsortedRecords.IndexOf(record); databaseGrid.GetTable("Customer Attendance").UnsortedRecords[index].Delete(); record.Delete(); database.Tables["Customers"].Rows[index].Delete(); database.Tables["Customer Attendance"].Rows[index].Delete(); database.AcceptChanges(); } else if (table == "Employee Schedule") { MessageBoxAdv.Show(this, "Cannot remove employee schedule entry directly. \n" + "To remove it, delete the corresponding employee entry.", "Error"); } else if (table == "Customer Attendance") { MessageBoxAdv.Show(this, "Cannot remove customer attendance entry directly. \n" + "To remove it, delete the corresponding customer entry.", "Error"); } } } catch (Exception) { MessageBoxAdv.Show(this, "Not a valid entry", "Error"); } }