1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
protected override void Paint
(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds,
int rowIndex, DataGridViewElementStates elementState, object value,
object formattedValue, string errorText, DataGridViewCellStyle cellStyle,
DataGridViewAdvancedBorderStyle advancedBorderStyle,
DataGridViewPaintParts paintParts)
{
OrderDetails l_oOrderDetails = (OrderDetails)this.OwningColumn.DataGridView.DataSource;
if (l_oOrderDetails != null)
{
int l_intOrderDetailId = Convert.ToInt32(value);
OrderDetail l_oOrderDetail = l_oOrderDetails.Find(delegate(OrderDetail l_ovalue) { return l_ovalue.OrderDetailId == l_intOrderDetailId; });
if (l_oOrderDetail != null)
{
if ((l_oOrderDetail.Status == OrderDetails.Validated()) || (l_oOrderDetail.Status == OrderDetails.Centralized()) || (l_oOrderDetail.Status == OrderDetails.Samic()))
{
value = true;
}
else
{
value = false;
}
//value = l_oOrderDetail.IsValidated;
formattedValue = value;
if ((l_oOrderDetail.Status == OrderDetails.Centralized()) || (l_oOrderDetail.Status == OrderDetails.Samic()) || (l_oOrderDetail.OrderId.CreationUser == Globals.UserName))
{
this.Enabled = false;
//this.ReadOnly = true;
}
else
{
this.Enabled = true;
//this.ReadOnly = false;
}
}
else
{
value = false;
formattedValue = value;
}
}
else
{
value = false;
formattedValue = value;
}
SolidBrush cellBackground = new SolidBrush(cellStyle.BackColor);
graphics.FillRectangle(cellBackground, cellBounds);
cellBackground.Dispose();
PaintBorder(graphics, clipBounds, cellBounds,
cellStyle, advancedBorderStyle);
Rectangle checkBoxArea = cellBounds;
Rectangle buttonAdjustment = this.BorderWidths(advancedBorderStyle);
checkBoxArea.X += buttonAdjustment.X;
checkBoxArea.Y += buttonAdjustment.Y;
checkBoxArea.Height -= buttonAdjustment.Height;
checkBoxArea.Width -= buttonAdjustment.Width;
Point drawInPoint = new Point(cellBounds.X + cellBounds.Width / 2 - 7,
cellBounds.Y + cellBounds.Height / 2 - 7);
if (this.enabledValue)
{
base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
}
else
{
if (this.RowIndex >= 0)
{
if ((bool)value == true)
{
CheckBoxRenderer.DrawCheckBox(graphics, drawInPoint, System.Windows.Forms.VisualStyles.CheckBoxState.CheckedDisabled);
}
else
{
CheckBoxRenderer.DrawCheckBox(graphics, drawInPoint, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedDisabled);
}
}
}
} |
Partager