private void ArrayIndexesChange(object sender, ArrayIndexesEventArgs e) { string threadName = Thread.CurrentThread.Name; this.Invoke(new MethodInvoker(() => { CustomDataGridView dataGridView = GetMainDataGridViewFromTabPage(tcSorters.TabPages[threadName]); if (dataGridView.FirstCellToRedraw != null && dataGridView.SecondCellToRedraw != null) { dataGridView[dataGridView.FirstCellToRedraw.Item2, dataGridView.FirstCellToRedraw.Item1].Style.BackColor = Color.White; dataGridView[dataGridView.SecondCellToRedraw.Item2, dataGridView.SecondCellToRedraw.Item1].Style.BackColor = Color.White; } dataGridView.FirstCellToRedraw = Utils.ConvertIndexOfOneDimensionalArray(e.FirstIndex, _formModel.ArrayForSorting.GetLength(0)); dataGridView.SecondCellToRedraw = Utils.ConvertIndexOfOneDimensionalArray(e.SecondIndex, _formModel.ArrayForSorting.GetLength(0)); dataGridView[dataGridView.FirstCellToRedraw.Item2, dataGridView.FirstCellToRedraw.Item1].Style.BackColor = Color.PaleVioletRed; dataGridView[dataGridView.SecondCellToRedraw.Item2, dataGridView.SecondCellToRedraw.Item1].Style.BackColor = Color.PaleVioletRed; dataGridView.Refresh(); })); }