DevExpress Immediate Post

Date: 2020-10-07
// Implement the System.ComponentModel.INotifyPropertyChanged interface
public class Item : INotifyPropertyChanged
{
	public event PropertyChangedEventHandler PropertyChanged;
	
	public bool Enabled {get;set;}
	private bool _checked;
	public bool Checked
	{
		get => _checked; set
		{
			_checked = Enabled ? value : _checked;
			PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Enabled)));
		}
	}
}

// On show editor (cell edit) subscribe to ActiveEditor.EditValueChanged
private void gridView_ShownEditor(object sender, EventArgs e)
{
	gridView.ActiveEditor.EditValueChanged += ActiveEditor_EditValueChanged;
}
// On each change PostEditor()
private void ActiveEditor_EditValueChanged(object sender, EventArgs e)
{
	gridView.PostEditor();
}

private void gridView_ShowingEditor(object sender, System.ComponentModel.CancelEventArgs e)
{
	if (gridView.GetFocusedRow() is Item listItem && !listItem.Enabled)
		e.Cancel = true;
}
41130cookie-checkDevExpress Immediate Post