Beispiel #1
0
        private void dataGridView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            Cell currentCell = this.test.GetCell(e.RowIndex, e.ColumnIndex);

            dataGridView[e.ColumnIndex, e.RowIndex].Value = currentCell.Text;
            Color newColor = Color.FromArgb((int)currentCell.BGColor);

            dataGridView[e.ColumnIndex, e.RowIndex].Style.BackColor = newColor;
            ICmd     text    = new RestoreText(currentCell, currentCell.Text);
            ICmd     bgcolor = new RestoreBGColor(currentCell, currentCell.BGColor);
            ICmd     multi   = new MultiCmd();
            MultiCmd temp    = multi as MultiCmd;

            temp.Add(text);
            temp.Add(bgcolor);
            test.AddUndo(multi);
        }
Beispiel #2
0
 private void changeColorToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (colorDialog.ShowDialog() == DialogResult.OK)
     {
         Color newColor = colorDialog.Color;            //Save the user selected color
         dataGridView.BackgroundColor = newColor;       //Save the new color in dataGridView.BackgroundColor
         var currentCells = dataGridView.SelectedCells; //Get the highlighted cells
         for (int i = 0; i < currentCells.Count; i++)
         {
             Cell currentCell = test.GetCell(currentCells[i].RowIndex, currentCells[i].ColumnIndex);
             currentCell.BGColor = (uint)newColor.ToArgb(); //Update the background color of each selected cell to the saved color the user selected
             ICmd     text    = new RestoreText(currentCell, currentCell.Text);
             ICmd     bgcolor = new RestoreBGColor(currentCell, currentCell.BGColor);
             ICmd     multi   = new MultiCmd();
             MultiCmd temp    = multi as MultiCmd;
             temp.Add(text);
             temp.Add(bgcolor);
             test.AddUndo(multi);
         }
     }
 }