Example #1
0
            protected override void Paint(
                Graphics graphics,
                Rectangle clipBounds,
                Rectangle cellBounds,
                int rowIndex,
                DataGridViewElementStates dataGridViewElementState,
                object value,
                object formattedValue,
                string errorText,
                DataGridViewCellStyle cellStyle,
                DataGridViewAdvancedBorderStyle advancedBorderStyle,
                DataGridViewPaintParts paintParts)
            {
                base.Paint(graphics, clipBounds, cellBounds, rowIndex,
                           dataGridViewElementState, value,
                           formattedValue, errorText, cellStyle,
                           advancedBorderStyle, paintParts);

                Point p = new Point();
                Size  s = CheckBoxRenderer.GetGlyphSize(graphics, CheckBoxState.UncheckedNormal);

                p.X = cellBounds.Location.X +
                      (cellBounds.Width / 2) - (s.Width / 2) - 1;
                p.Y = cellBounds.Location.Y +
                      (cellBounds.Height / 2) - (s.Height / 2);

                _cellLocation    = cellBounds.Location;
                checkBoxLocation = p;
                checkBoxSize     = s;
                if (_checked)
                {
                    _cbState = System.Windows.Forms.VisualStyles.
                               CheckBoxState.CheckedNormal;
                }
                else
                {
                    _cbState = System.Windows.Forms.VisualStyles.
                               CheckBoxState.UncheckedNormal;
                }

                CheckBoxRenderer.DrawCheckBox
                    (graphics, checkBoxLocation, _cbState);
            }
 protected override void Paint(System.Drawing.Graphics graphics,
     System.Drawing.Rectangle clipBounds,
     System.Drawing.Rectangle cellBounds,
     int rowIndex,
     DataGridViewElementStates dataGridViewElementState,
     object value,
     object formattedValue,
     string errorText,
     DataGridViewCellStyle cellStyle,
     DataGridViewAdvancedBorderStyle advancedBorderStyle,
     DataGridViewPaintParts paintParts)
 {
     base.Paint(graphics, clipBounds, cellBounds, rowIndex,
         dataGridViewElementState, value,
         formattedValue, errorText, cellStyle,
         advancedBorderStyle, paintParts);
     Point p = new Point();
     Size s = CheckBoxRenderer.GetGlyphSize(graphics,
     System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal);
     p.X = cellBounds.Location.X +
         (cellBounds.Width / 2) - (s.Width / 2);
     p.Y = cellBounds.Location.Y +
         (cellBounds.Height / 2) - (s.Height / 2);
     _cellLocation = cellBounds.Location;
     checkBoxLocation = p;
     checkBoxSize = s;
     if (_checked)
         _cbState = System.Windows.Forms.VisualStyles.
             CheckBoxState.CheckedNormal;
     else
         _cbState = System.Windows.Forms.VisualStyles.
             CheckBoxState.UncheckedNormal;
     CheckBoxRenderer.DrawCheckBox
     (graphics, checkBoxLocation, _cbState);
 }