public void UpdateRow(object CellsObj) { if (this.InvokeRequired) { UpdateRow_d URD = new UpdateRow_d(UpdateRow); this.Invoke(URD, new object[] { CellsObj }); } else { object[] CellsArray = Tools.ToDotNetArray(CellsObj); if (CellsArray.Length == 0 || CellsArray[0] == null) { throw new Exception("ID not provided"); } int GridId = -1; try { int ID = Int32.Parse(CellsArray[0].ToString()); if (GridMap.ContainsKey(ID)) { GridId = GridMap[ID]; } }catch {} if (GridId == -1 || !this.Rows[GridId].Cells[0].Value.ToString().Equals(CellsArray[0].ToString())) { foreach (DataGridViewRow Row in this.Rows) { if (Row.Cells[0].Value.ToString().Equals(CellsArray[0].ToString())) { GridId = Row.Index; break; } } } if (GridId == -1) { throw new Exception("ID is missing in the Grid"); } for (int i = 1; i < CellsArray.Length; i++) { if (CellsArray[i] != null) { this.Rows[GridId].Cells[i].Value = CellsArray[i]; } } } }
public void UpdateRow(object CellsObj) { if (this.InvokeRequired) { UpdateRow_d URD = new UpdateRow_d(UpdateRow); this.Invoke(URD, new object[] { CellsObj }); } else { object[] CellsArray = Tools.ToDotNetArray(CellsObj); if(CellsArray.Length == 0 || CellsArray[0] == null) { throw new Exception("ID not provided"); } int GridId = -1; try { int ID = Int32.Parse(CellsArray[0].ToString()); if(GridMap.ContainsKey(ID)) GridId = GridMap[ID]; }catch{} if(GridId == -1 || !this.Rows[GridId].Cells[0].Value.ToString().Equals(CellsArray[0].ToString())) { foreach(DataGridViewRow Row in this.Rows) { if(Row.Cells[0].Value.ToString().Equals(CellsArray[0].ToString())) { GridId = Row.Index; break; } } } if(GridId == -1) { throw new Exception("ID is missing in the Grid"); } for(int i=1; i < CellsArray.Length; i++) { if (CellsArray[i] != null) this.Rows[GridId].Cells[i].Value = CellsArray[i]; } } }