private void GridView_DragDrop(object sender, DragEventArgs e) { DataGridView grid = (DataGridView)sender; Point clientPoint = grid.PointToClient(new Point(e.X, e.Y)); rowIndexOfItemUnderMouseToDrop = grid.HitTest(clientPoint.X, clientPoint.Y).RowIndex; if (rowIndexOfItemUnderMouseToDrop == -1) { return; } if (e.Effect == DragDropEffects.Move) { DataGridViewRow rowToMove = e.Data.GetData(typeof(DataGridViewRow)) as DataGridViewRow; if (rowIndexOfItemUnderMouseToDrop >= (grid.RowCount - 1)) // Blocca il drag fuori dalle celle salvate { return; } if (rowIndexFromMouseDown >= (grid.RowCount - 1)) // Blocca il drag di una cella non salvata { return; } grid.Rows.RemoveAt(rowIndexFromMouseDown); grid.Rows.Insert(rowIndexOfItemUnderMouseToDrop, rowToMove); switch (grid.Name) { case "autolootdataGridView": AutoLoot.CopyTable(); break; case "scavengerdataGridView": Scavenger.CopyTable(); break; case "organizerdataGridView": Organizer.CopyTable(); break; case "vendorbuydataGridView": BuyAgent.CopyTable(); break; case "vendorsellGridView": SellAgent.CopyTable(); break; case "restockdataGridView": Restock.CopyTable(); break; case "graphfilterdatagrid": RazorEnhanced.Filters.CopyGraphTable(); break; } } }
private void GridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { DataGridView grid = (DataGridView)sender; if (!grid.Focused) { return; } if (e.ColumnIndex == 0) // Checkbox cambiate di stato genera save { switch (grid.Name) { case "autolootdataGridView": AutoLoot.CopyTable(); break; case "scavengerdataGridView": Scavenger.CopyTable(); break; case "organizerdataGridView": Organizer.CopyTable(); break; case "vendorbuydataGridView": BuyAgent.CopyTable(); break; case "vendorsellGridView": SellAgent.CopyTable(); break; case "restockdataGridView": Restock.CopyTable(); break; case "graphfilterdatagrid": RazorEnhanced.Filters.CopyGraphTable(); break; case "journalfilterdatagrid": RazorEnhanced.Filters.CopyJournalFilterTable(); break; } } }
private void SaveData() { List <Scavenger.ScavengerItem.Property> propslist = new List <Scavenger.ScavengerItem.Property>(); foreach (DataGridViewRow row in scavengerpropGridView.Rows) { if (row.IsNewRow) { continue; } int min = Convert.ToInt32((string)row.Cells[1].Value); int max = Convert.ToInt32((string)row.Cells[2].Value); string propname = string.Empty; if (row.Cells[0].Value != null) { propname = row.Cells[0].Value.ToString(); } propslist.Add(new Scavenger.ScavengerItem.Property(propname, min, max)); } m_row.Cells[4].Value = propslist; Scavenger.CopyTable(); }