Inheritance: EntitySimple
Ejemplo n.º 1
0
      /// <summary>
      /// 绑定数据源 符合entitysimple规则,列依次为GUID/Code/Name/...
      /// </summary>
      /// <param name="dtSource"></param>
      /// <param name="checkGUIDs"></param>
      /// <exception cref="ArgumentNullException"></exception>
      public void Binding(DataTable dtSource, string[] checkGUIDs)
      {
         if (dtSource == null) throw new ArgumentNullException("dtSource");

         _dtSource = dtSource;
         _isCheckedOfSource = new bool[dtSource.Rows.Count];

         if (checkGUIDs.Length == dtSource.Rows.Count)
         {
            chbxAll.CheckState = CheckState.Checked;
         }
         else if (checkGUIDs.Length == 0)
         {
            chbxAll.CheckState = CheckState.Unchecked;            
         }
         else
         {
            chbxAll.CheckState = CheckState.Indeterminate;            
         }

         for (int i = 0; i < _dtSource.Rows.Count; i++)
         {
            _isCheckedOfSource[i] = Array.IndexOf(checkGUIDs, _dtSource.Rows[i][0].ToString()) != -1;
            EntityCheckedBox entity = new EntityCheckedBox(_dtSource.Rows[i], _isCheckedOfSource[i], i);
            lstCheckBox.Items.Add(entity, entity.IsChecked);
         }

         this.lstCheckBox.ItemCheck += this.lstCheckBox_ItemCheck;
         this.lstCheckBox.ItemCheck += this.lstCheckBox_ItemCheck_Checked;
         this.chbxAll.CheckStateChanged +=  this.chbxAll_CheckStateChanged;
      }
Ejemplo n.º 2
0
        /// <summary>
        /// 绑定数据源 符合entitysimple规则,列依次为GUID/Code/Name/...
        /// </summary>
        /// <param name="dtSource"></param>
        /// <param name="checkGUIDs"></param>
        /// <exception cref="ArgumentNullException"></exception>
        public void Binding(DataTable dtSource, string[] checkGUIDs)
        {
            if (dtSource == null)
            {
                throw new ArgumentNullException("dtSource");
            }

            _dtSource          = dtSource;
            _isCheckedOfSource = new bool[dtSource.Rows.Count];

            if (checkGUIDs.Length == dtSource.Rows.Count)
            {
                chbxAll.CheckState = CheckState.Checked;
            }
            else if (checkGUIDs.Length == 0)
            {
                chbxAll.CheckState = CheckState.Unchecked;
            }
            else
            {
                chbxAll.CheckState = CheckState.Indeterminate;
            }

            for (int i = 0; i < _dtSource.Rows.Count; i++)
            {
                _isCheckedOfSource[i] = Array.IndexOf(checkGUIDs, _dtSource.Rows[i][0].ToString()) != -1;
                EntityCheckedBox entity = new EntityCheckedBox(_dtSource.Rows[i], _isCheckedOfSource[i], i);
                lstCheckBox.Items.Add(entity, entity.IsChecked);
            }

            this.lstCheckBox.ItemCheck     += this.lstCheckBox_ItemCheck;
            this.lstCheckBox.ItemCheck     += this.lstCheckBox_ItemCheck_Checked;
            this.chbxAll.CheckStateChanged += this.chbxAll_CheckStateChanged;
        }
Ejemplo n.º 3
0
        void BindData()
        {
            if (_dtSource == null)
            {
                throw new ArgumentNullException("请使用Binding方法绑定");
            }

            this.lstCheckBox.ItemCheck -= this.lstCheckBox_ItemCheck_Checked;

            this.chbxAll.CheckStateChanged -= this.chbxAll_CheckStateChanged;
            chbxAll.CheckState              = CheckState.Unchecked;
            this.chbxAll.CheckStateChanged += this.chbxAll_CheckStateChanged;

            lstCheckBox.Items.Clear();

            DataRow[] rows = _dtSource.Select(_filter);

            for (int i = 0; i < rows.Length; i++)
            {
                int index = _dtSource.Rows.IndexOf(rows[i]);
                EntityCheckedBox entity = new EntityCheckedBox(rows[i], _isCheckedOfSource[index], index);
                lstCheckBox.Items.Add(entity, entity.IsChecked);
            }

            this.lstCheckBox.ItemCheck += this.lstCheckBox_ItemCheck_Checked;
        }
Ejemplo n.º 4
0
        ///这个与上面的事件不同之处,只是用来保存选择的集合
        private void lstCheckBox_ItemCheck_Checked(object sender, ItemCheckEventArgs e)
        {
            this.chbxAll.CheckStateChanged -= this.chbxAll_CheckStateChanged;

            EntityCheckedBox entity = lstCheckBox.Items[e.Index] as EntityCheckedBox;

            _isCheckedOfSource[entity.IndexOfSource] = e.NewValue == CheckState.Checked;

            this.chbxAll.CheckStateChanged += this.chbxAll_CheckStateChanged;
        }
Ejemplo n.º 5
0
      void BindData()
      {
         if (_dtSource == null) throw new ArgumentNullException("请使用Binding方法绑定");

         this.lstCheckBox.ItemCheck -= this.lstCheckBox_ItemCheck_Checked;

         this.chbxAll.CheckStateChanged -= this.chbxAll_CheckStateChanged;
         chbxAll.CheckState = CheckState.Unchecked;
         this.chbxAll.CheckStateChanged += this.chbxAll_CheckStateChanged;

         lstCheckBox.Items.Clear();

         DataRow[] rows = _dtSource.Select(_filter);

         for (int i = 0; i < rows.Length; i++)
         {
            int index = _dtSource.Rows.IndexOf(rows[i]);
            EntityCheckedBox entity = new EntityCheckedBox(rows[i], _isCheckedOfSource[index], index);
            lstCheckBox.Items.Add(entity, entity.IsChecked);
         }

         this.lstCheckBox.ItemCheck += this.lstCheckBox_ItemCheck_Checked;
      }