I would like to draw a red border around a DataGridView
cell while it\'s being edited.
I\'ve managed to draw a red border around the selected cell while
It seems like the EditingControl
is hosted in a parent Panel
, and if you set the Opaque
style of that panel to true, then the border will be painted.
E.g.
void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) {
var c = e.Control;
var p = c.Parent;
SetStyles(p, ControlStyles.Opaque, true);
}
private static void SetStyles(Control c, ControlStyles styles, bool value) {
MethodInfo mi = typeof(Control).GetMethod("SetStyle", BindingFlags.NonPublic | BindingFlags.Instance);
mi.Invoke(c, new Object[] { styles, value });
}