Example #1
0
        /// <summary>
        /// Changes given cell based on it's formatting
        /// </summary>
        /// <param name="cell"></param>
        /// <param name="isFormattingCorrect"></param>
        private void SetCell(DataGridViewCell cell, bool isFormattingCorrect)
        {
            if (isFormattingCorrect)
            {
                if (BadCells.Contains(cell))
                {
                    BadCells.Remove(cell);
                }
                cell.Style.BackColor = Color.PaleGreen;
            }
            else
            {
                if (!BadCells.Contains(cell))
                {
                    BadCells.Add(cell);
                }
                cell.Style.BackColor = Color.IndianRed;
            }

            if (MainGridView.Columns[cell.ColumnIndex].Name == "Apartment")
            {
                if (!ChangedCells.Contains(cell))
                {
                    cell.Style.BackColor = Color.Empty;
                }
            }
        }
Example #2
0
        private void DataGridView2_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewCell currentCell = MainGridView[e.ColumnIndex, e.RowIndex];

            //Prevents cell from staying white after it was edited
            if (ChangedCells.Contains(currentCell))
            {
                SetCell(currentCell, CheckCell(currentCell));
            }
        }
Example #3
0
        /// <summary>
        /// Remove cells inside the given row.
        /// </summary>
        /// <param name="row"></param>
        private void DeleteCellsFromRow(DataGridViewRow row)
        {
            foreach (DataGridViewCell cell in row.Cells)
            {
                if (ChangedCells.Contains(cell))
                {
                    ChangedCells.Remove(cell);
                }
                if (BadCells.Contains(cell))
                {
                    BadCells.Remove(cell);
                }
            }

            if (!BadCells.Any())
            {
                SetButtons(true, true, true);
            }
        }