Exemple #1
0
        /*public static bool IsFill(Control ctl, ErrorProvider ep, ref bool isLastPass, string displayName = "")
         * {
         *  const string notfill = "未填写";
         *  if (ctl is LabelTextBox)
         *  {
         *      if ((ctl as LabelTextBox).TextBoxText == string.Empty)
         *      {
         *          ep.SetError(ctl, (displayName == string.Empty ? (ctl as LabelTextBox).LabelText : displayName) + notfill);
         *          if (isLastPass == true)
         *          {
         *              ctl.Focus();
         *              isLastPass = false;
         *          }
         *      }
         *  }
         *  else if (ctl is LabelSelectBox)
         *  {
         *      if ((ctl as LabelSelectBox).TextBoxText == string.Empty)
         *      {
         *          ep.SetError(ctl, (displayName == string.Empty ? (ctl as LabelSelectBox).LabelText : displayName) + notfill);
         *          if (isLastPass == true)
         *          {
         *              ctl.Focus();
         *              isLastPass = false;
         *          }
         *      }
         *  }
         *  return isLastPass;
         * }*/

        public static void ChangeMenuItem(bool toState, ToolStripItemCollection menuItems, ToolStripItemCollection exclusionMenuItems)
        {
            foreach (ToolStripItem i in menuItems)
            {
                if (i is ToolStripMenuItem)
                {
                    var mi = (ToolStripMenuItem)i;
                    if (mi.HasDropDownItems)
                    {
                        ChangeMenuItem(toState, mi.DropDownItems, exclusionMenuItems);
                    }
                    else
                    {
                        if (exclusionMenuItems != null && exclusionMenuItems.Contains(mi))
                        {
                            mi.Enabled = !toState;
                        }
                        else
                        {
                            mi.Enabled = toState;
                        }
                    }
                }
            }
        }
 private static void ToggleItem(ToolStripItemCollection items, ToolStripItem item, bool visible, bool first = false)
 {
     if (visible)
     {
         if (first)
         {
             items.Insert(0, item);
         }
         else
         {
             items.Add(item);
         }
     }
     else if (items.Contains(item))
     {
         items.Remove(item);
     }
 }
 public bool Contains(IBarItem item)
 {
     return(collection.Contains(item as ToolStripItem));
 }