DataGridViewCheckBoxCell
CheckBox の値を反映する CheckBox の右側の文字列を含むように a を変更しました。の場合true
、文字列は「Value1」です。その場合false
、文字列は「Value2」に変更されます。
文字列値は、DataGridViewCheckBoxCell
フォーカスが失われた後にのみ変更されます。CheckBox 値が変更された直後に文字列値を変更したい。どうやってやるの?
参考までに、これは私のパーソナライズされたDataGridViewCheckBoxCell
クラスです。
public class MyDGVCheckBoxCell : DataGridViewCheckBoxCell
{
public static string TRUE_VALUE = "Excitada";
public static string FALSE_VALUE = "Monitorada";
public MyDGVCheckBoxCell(bool isExcitada)
{
FalseValue = FALSE_VALUE;
TrueValue = TRUE_VALUE;
Value = isExcitada ? TRUE_VALUE : FALSE_VALUE;
}
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)
{
base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
Rectangle contentBounds = this.GetContentBounds(rowIndex);
Point stringLocation = new Point();
stringLocation.Y = cellBounds.Y + 4;
stringLocation.X = cellBounds.X + contentBounds.Right + 1;
graphics.DrawString(this.Value.ToString(), Control.DefaultFont, System.Drawing.Brushes.Black, stringLocation);
}
}