BrightIdeasSoftware.ObjectListView.SetObjectCheckedness C# (CSharp) Method

SetObjectCheckedness() protected method

Change the check state of the given object to be the given state.
If the given model object isn't in the list, we still try to remember its state, in case it is referenced in the future.
protected SetObjectCheckedness ( object modelObject, CheckState state ) : void
modelObject object
state CheckState
return void
        protected virtual void SetObjectCheckedness(object modelObject, CheckState state)
        {
            OLVListItem olvi = this.ModelToItem(modelObject);

            // If we didn't find the given, we still try to record the check state.
            if (olvi == null) {
                this.PutCheckState(modelObject, state);
                return;
            }

            if (olvi.CheckState == state)
                return;

            // Trigger checkbox changing event. We only need to do this for virtual
            // lists, since setting CheckState triggers these events for non-virtual lists
            ItemCheckEventArgs ice = new ItemCheckEventArgs(olvi.Index, state, olvi.CheckState);
            this.OnItemCheck(ice);
            if (ice.NewValue == olvi.CheckState)
                return;

            olvi.CheckState = this.PutCheckState(modelObject, state);
            this.RefreshItem(olvi);

            // Trigger check changed event
            this.OnItemChecked(new ItemCheckedEventArgs(olvi));
        }
ObjectListView