Example #1
0
        public void ToggleState()
        {
            RadCheckBoxEditorElement editorElement = (RadCheckBoxEditorElement)this.EditorElement;

            if (this.ThreeState)
            {
                switch (editorElement.CheckState)
                {
                case Telerik.WinControls.Enumerations.ToggleState.Off:
                    this.Value = (object)Telerik.WinControls.Enumerations.ToggleState.On;
                    break;

                case Telerik.WinControls.Enumerations.ToggleState.On:
                    this.Value = (object)Telerik.WinControls.Enumerations.ToggleState.Indeterminate;
                    break;

                case Telerik.WinControls.Enumerations.ToggleState.Indeterminate:
                    this.Value = (object)Telerik.WinControls.Enumerations.ToggleState.Off;
                    break;
                }
            }
            else if (editorElement.CheckState == Telerik.WinControls.Enumerations.ToggleState.Off || editorElement.CheckState == Telerik.WinControls.Enumerations.ToggleState.Indeterminate)
            {
                this.Value = (object)Telerik.WinControls.Enumerations.ToggleState.On;
            }
            else
            {
                this.Value = (object)Telerik.WinControls.Enumerations.ToggleState.Off;
            }
        }
Example #2
0
        private void SetValue(object value)
        {
            Telerik.WinControls.Enumerations.ToggleState toggleState = (Telerik.WinControls.Enumerations.ToggleState)value;
            if (!this.threeState && toggleState == Telerik.WinControls.Enumerations.ToggleState.Indeterminate)
            {
                toggleState = Telerik.WinControls.Enumerations.ToggleState.Off;
            }
            RadCheckBoxEditorElement editorElement = this.EditorElement as RadCheckBoxEditorElement;

            if (this.IsInitalizing)
            {
                editorElement.CheckState = toggleState;
            }
            else
            {
                object newValue = (object)null;
                object oldValue = (object)null;
                switch (toggleState)
                {
                case Telerik.WinControls.Enumerations.ToggleState.Off:
                case Telerik.WinControls.Enumerations.ToggleState.Indeterminate:
                    newValue = (object)false;
                    break;

                case Telerik.WinControls.Enumerations.ToggleState.On:
                    newValue = (object)true;
                    break;
                }
                switch (editorElement.CheckState)
                {
                case Telerik.WinControls.Enumerations.ToggleState.Off:
                case Telerik.WinControls.Enumerations.ToggleState.Indeterminate:
                    oldValue = (object)false;
                    break;

                case Telerik.WinControls.Enumerations.ToggleState.On:
                    oldValue = (object)true;
                    break;
                }
                ValueChangingEventArgs e = new ValueChangingEventArgs(newValue, oldValue);
                this.OnValueChanging(e);
                if (e.Cancel)
                {
                    return;
                }
                editorElement.CheckState = toggleState;
                this.OnValueChanged();
            }
        }