The easiest way to do this, if possible, is to check the value at entity level.
For example, let's say we have the following simplified entity Foo ;
public class Foo { private readonly int id; private int type; private string name; public Foo(int id, int type, string name) { this.id = id; this.type = type; this.name = name; } public int Id { get { return this.id; } } public int Type { get { return this.type; } set { if (this.type != value) { if (value >= 0 && value <= 5)
Now we can bind to our DataGridView a List<Foo> foos , and we will effectively mask any input in the "Type" DataGridViewColumn .
If this is not a valid path, simply handle the CellEndEdit event and confirm the entry.
Inbetween
source share