protected override void OnStateChanged(BulkEditorAdapter sender, BulkEditorStateEventArgs e)
 {
     base.OnStateChanged(sender, e);
     if (string.Equals(e.PropertyName, "Checked"))
     {
         AutoHeightCheckBox autoHeightCheckBox = base.HostControl as AutoHeightCheckBox;
         if (base["Checked"] != null && base["Checked"] != 3)
         {
             bool @checked = autoHeightCheckBox.Checked;
             this.forceAllowCheckedChangedEvent = true;
             autoHeightCheckBox.Checked         = autoHeightCheckBox.BulkEditDefaultChecked;
             this.forceAllowCheckedChangedEvent = false;
             autoHeightCheckBox.Checked         = @checked;
             Binding binding = autoHeightCheckBox.DataBindings["Checked"];
             if (binding != null)
             {
                 binding.WriteValue();
             }
         }
         else if (base["Checked"] != 3)
         {
             autoHeightCheckBox.Checked = false;
         }
     }
     base.HostControl.Invalidate();
 }
Пример #2
0
        public void BindCheckBoxToFlag(AutoHeightCheckBox checkBox, T flag)
        {
            if (checkBox == null)
            {
                throw new ArgumentNullException("checkBox");
            }
            ulong   flagValue = Convert.ToUInt64(flag);
            Binding binding   = checkBox.DataBindings.Add("Checked", this.dataSource, this.dataMember, true, DataSourceUpdateMode.OnPropertyChanged);

            binding.Format += delegate(object sender, ConvertEventArgs e)
            {
                this.currentEnumValue = ((e.Value == null) ? 0UL : Convert.ToUInt64(e.Value));
                e.Value = ((this.currentEnumValue & flagValue) == flagValue);
            };
            binding.Parse += delegate(object sender, ConvertEventArgs e)
            {
                if (true.Equals(e.Value))
                {
                    e.Value = Enum.ToObject(typeof(T), this.currentEnumValue | flagValue);
                    return;
                }
                e.Value = Enum.ToObject(typeof(T), this.currentEnumValue & ~flagValue);
            };
        }
 public CheckBoxBulkEditorAdapter(AutoHeightCheckBox checkBox) : base(checkBox)
 {
 }