コード例 #1
0
        InsertItemIntoVertexComboBox
        (
            ObjectWithText oItemToInsert,
            ComboBox cbxVertex
        )
        {
            Debug.Assert(cbxVertex != null);
            AssertValid();

            ComboBox.ObjectCollection oItems = cbxVertex.Items;
            Int32 iItems = oItems.Count;

            Int32 iColumnToInsertOneBased =
                ObjectWithTextToColumnNumberOneBased(oItemToInsert);

            Int32 i;

            for (i = 0; i < iItems; i++)
            {
                Debug.Assert(oItems[i] is ObjectWithText);

                ObjectWithText oItem = (ObjectWithText)oItems[i];

                if (iColumnToInsertOneBased <
                    ObjectWithTextToColumnNumberOneBased(oItem))
                {
                    break;
                }
            }

            oItems.Insert(i, oItemToInsert);
        }
コード例 #2
0
ファイル: FormMonitor.cs プロジェクト: Droo-k6/School
        // add given string to ComboBox at beginning
        private void MonitorExtDropdownInsert(string str)
        {
            // check that string isn't empty
            if (str.Length <= 0)
            {
                return;
            }

            // convert str to lowercase
            str = str.ToLower();

            // pull Items from control
            ComboBox.ObjectCollection extComboList = ComboBoxMonitorExt.Items;

            // check that string is not equal to current value at beginning
            // check if list contains anything
            // could use IndexOf(str), but don't want to deal with if it starts at the end or beginning of the collection
            if (extComboList.Count > 0)
            {
                // check if equals, return
                if (str == (string)extComboList[0])
                {
                    return;
                }
            }

            // if size is at max, remove last entry
            if (extComboList.Count == extHistoryMax)
            {
                extComboList.RemoveAt(extComboList.Count - 1);
            }

            // insert at beginning
            extComboList.Insert(0, str);
        }
コード例 #3
0
        public CreatTask(ScheduleForm form, ListView view)
        {
            InitializeComponent();
            scheduleform = form;
            listView     = view;

            int i = 1;

            ComboBox.ObjectCollection Macs = new ComboBox.ObjectCollection(Computers);
            Macs.Insert(0, "");
            foreach (ListViewItem item in view.Items)
            {
                if (i != view.Items.Count)
                {
                    Macs.Insert(i, item.SubItems[1].Text);
                    i++;
                }
            }
            Computers.DataSource = Macs;
        }
コード例 #4
0
        /// <summary>
        /// Perform the save operation to save the friend's data
        /// </summary>
        /// <returns>true if succeeded, false if not succeeded</returns>
        private bool PerformSaveOp()
        {
            // Check if saving is valid
            bool notValid = string.IsNullOrWhiteSpace(this.friendSheet.Friend.Name);

            if (notValid)
            {
                MessageBox.Show(
                    "Saving failed, name cannot be empty or only have whitespace",
                    "Cannot save",
                    MessageBoxButtons.OK);
                return(false);
            }

            // Save friend sheet
            this.friendSheet.SaveFriend();

            // Save lists
            this.listBring.SaveItemList();
            this.listWant.SaveItemList();

            Friend friend = this.friendSheet.Friend;

            friend.ListBring = this.listBring.Items;
            friend.ListWant  = this.listWant.Items;

            int index = this.ComboBoxFriends.SelectedIndex;

            ComboBox.ObjectCollection items = this.ComboBoxFriends.Items;

            if (index == -1)
            {
                // If index is -1 (new entry) then prepare the index to be 0 for later insertion
                index = 0;
            }
            else
            {
                // If index is something other than -1 (existing entry), remove the entry at that index
                // (supposedly the friend object with "outdated" params) to have the new friend entry
                // be added in as a replacement.
                items.RemoveAt(index);
            }

            // Insert the friend object at the designated index
            items.Insert(index, friend);

            // Have the combo box select the entry corresponding to that index
            this.ComboBoxFriends.SelectedIndex = index;

            return(true);
        }
コード例 #5
0
ファイル: Form_LightOrders.cs プロジェクト: Joni1010/market
        private void updateAllComboBoxSec()
        {
            Qlog.CatchException(() =>
            {
                foreach (var pan in ListPanels)
                {
                    if (pan.ComboboxSecurity.NotIsNull())
                    {
                        pan.ComboboxSecurity.DataSource = null;
                        pan.ComboboxSecurity.Clear();

                        ComboBox.ObjectCollection items = new ComboBox.ObjectCollection(pan.ComboboxSecurity);
                        items.Insert(0, " ");
                        foreach (var itemSec in Settings.Get("ItemsSec"))
                        {
                            items.Add(itemSec.SecAndClass);
                        }
                        pan.ComboboxSecurity.DataSource = items;
                    }
                }
                LoadStructPanels();
            });
        }