J'ai les éléments suivants: DataGridViewCheckBoxCell
. le problème est la mise à jour visuelle ne se fait pas immédiatement dans le mode d'édition, seulement quand je le quitteLa mise à jour visuelle DataGridViewCheckBoxCell personnalisée ne fonctionne pas en mode édition
public class CustomDataGridViewCell : DataGridViewCheckBoxCell
{
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, DataGridViewPaintParts.All & ~DataGridViewPaintParts.ContentForeground);
var val = (bool?)FormattedValue;
var img = val.HasValue && val.Value ? Properties.Resources._checked : Properties.Resources._unchecked;
var w = img.Width;
var h = img.Height;
var x = cellBounds.Left + (cellBounds.Width - w)/2;
var y = cellBounds.Top + (cellBounds.Height - h)/2;
graphics.DrawImage(img, new Rectangle(x, y, w, h));
}
}
Eh oui, il était formattedValue le paramètre du problème. Je me sens gêné * soupir * – ihisham