2007-08-28 Jonathan Pobst <monkey@jpobst.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / DataGridViewCellPaintingEventArgs.cs
index 468fa255f0d50894f7025ce2d022da740f07e1af..10472a20e69e81df8c58d9f7cdcdf8205b39347b 100644 (file)
@@ -112,14 +112,41 @@ namespace System.Windows.Forms {
                }
 
                public void Paint (Rectangle clipBounds, DataGridViewPaintParts paintParts) {
+                       if (rowIndex < -1 || rowIndex >= dataGridView.Rows.Count) {
+                               throw new InvalidOperationException("Invalid \"RowIndex.\"");
+                       }
+                       if (columnIndex < -1 || columnIndex >= dataGridView.Columns.Count) {
+                               throw new InvalidOperationException("Invalid \"ColumnIndex.\"");
+                       }
                        throw new NotImplementedException();
                }
 
-               public void PaintBackground( Rectangle clipBounds, bool cellsPaintSelectionBackground) {
-                       throw new NotImplementedException();
+               public void PaintBackground (Rectangle clipBounds, bool cellsPaintSelectionBackground) {
+                       if (rowIndex < -1 || rowIndex >= dataGridView.Rows.Count) {
+                               throw new InvalidOperationException("Invalid \"RowIndex.\"");
+                       }
+                       if (columnIndex < -1 || columnIndex >= dataGridView.Columns.Count) {
+                               throw new InvalidOperationException("Invalid \"ColumnIndex.\"");
+                       }
+                       DataGridViewCell cell = dataGridView.Rows[rowIndex].Cells[columnIndex];
+                       Color color;
+                       if (cellsPaintSelectionBackground) {
+                               color = cell.InheritedStyle.SelectionBackColor;
+                       }
+                       else {
+                               color = cell.InheritedStyle.BackColor;
+                       }
+                       ///////// NOT CHECKED //////////////
+                       graphics.FillRectangle(new SolidBrush(color), clipBounds);
                }
 
                public void PaintContent (Rectangle clipBounds) {
+                       if (rowIndex < -1 || rowIndex >= dataGridView.Rows.Count) {
+                               throw new InvalidOperationException("Invalid \"RowIndex.\"");
+                       }
+                       if (columnIndex < -1 || columnIndex >= dataGridView.Columns.Count) {
+                               throw new InvalidOperationException("Invalid \"ColumnIndex.\"");
+                       }
                        throw new NotImplementedException();
                }