예제 #1
0
        public static void AddItems <TItem>(this ListBox listBox, TItem[] items, bool clearItemsBeforeAdd = true, bool throwIfNull = false)
        {
            if (clearItemsBeforeAdd)
            {
                listBox.ClearItemsIfExist();
            }

            if (items == null)
            {
                if (throwIfNull)
                {
                    throw new ArgumentNullException(ReflectionUtils.GetNameOf(() => items), "Nie przekazano elementów do dodania.");
                }
                else
                {
                    return;
                }
            }

            items.ForEach(x => listBox.Items.Add(x));
        }