コード例 #1
0
 protected override void OnBeforeCellCheck(Cell cell, AdvTreeCellBeforeCheckEventArgs e)
 {
     if (this.IsReadOnly && e.Action != eTreeAction.Code)
         e.Cancel = true;
     else
     {
         if (e.Action != eTreeAction.Code)
         {
             bool newValue = (e.NewCheckState == System.Windows.Forms.CheckState.Checked);
             e.Cancel = !ApplyValue(newValue, null);
         }
     }
     base.OnBeforeCellCheck(cell, e);
 }
コード例 #2
0
ファイル: Cell.cs プロジェクト: huamanhtuyen/VNACCS
        /// <summary>
        /// Sets the Checked or CheckState properties.
        /// </summary>
        /// <param name="value">New value for checked state.</param>
        /// <param name="actionSource">Action source.</param>
        public void SetChecked(CheckState value, eTreeAction actionSource)
        {
            AdvTreeCellBeforeCheckEventArgs beforeCheckArgs = new AdvTreeCellBeforeCheckEventArgs(actionSource, this, value);
            InvokeBeforeCheck(beforeCheckArgs);
            if (beforeCheckArgs.Cancel) return;

            _CheckState = value;
            m_Checked = value == CheckState.Checked;
            OnAppearanceChanged();

            if (this.CheckBoxStyle == eCheckBoxStyle.RadioButton && value == CheckState.Checked && this.Parent != null)
            {
                Node parent = this.Parent;
                AdvTree tree = parent.TreeControl;
                if (tree != null) tree.BeginUpdate();
                bool processNodes = true;
                foreach (Cell item in parent.Cells)
                {
                    if (item == this) continue;
                    if (item.CheckBoxStyle == eCheckBoxStyle.RadioButton)
                    {
                        item.Checked = false;
                        processNodes = false;
                    }
                }
                if (processNodes)
                {
                    if (parent.Parent != null)
                    {
                        foreach (Node item in parent.Parent.Nodes)
                        {
                            if (item != parent && item.CheckBoxStyle == eCheckBoxStyle.RadioButton)
                                item.Checked = false;
                        }
                    }
                    else
                    {
                        if (tree != null && NodeOperations.IsRootNode(tree, parent))
                        {
                            foreach (Node item in tree.Nodes)
                            {
                                if (item != parent && item.CheckBoxStyle == eCheckBoxStyle.RadioButton)
                                    item.Checked = false;
                            }
                        }
                    }
                }
                if (tree != null) tree.EndUpdate();
            }

            InvokeAfterCheck(actionSource);
        }
コード例 #3
0
ファイル: Cell.cs プロジェクト: huamanhtuyen/VNACCS
        /// <summary>
        /// Invokes <see cref="AdvTree.BeforeCheck">BeforeCheck</see> event on AdvTree
        /// control.
        /// </summary>
        protected virtual void InvokeBeforeCheck(AdvTreeCellBeforeCheckEventArgs e)
        {
            AdvTree tree = this.TreeControl;
            if (tree != null)
            {
                tree.InvokeBeforeCheck(e);
            }

            if (this.Parent != null)
                this.Parent.BeforeCellCheck(this, e);
        }
コード例 #4
0
 void layersList_BeforeCheck(object sender, AdvTreeCellBeforeCheckEventArgs e)
 {
     if (Control.MouseButtons != MouseButtons.Left)
         e.Cancel = true;
 }