Esempio n. 1
0
 public override void DataBind()
 {
     base.DataBind();
     RightListBox.DataTextField  = this.DataTextField;
     RightListBox.DataValueField = this.DataValueField;
     RightListBox.DataBind();
     BaseItems.Clear();
     for (int index = 0; index < RightListBox.Items.Count; index++)
     {
         this.Items.Remove(this.Items.FindByValue(RightListBox.Items[index].Value));
         if (!BaseItems.ContainsKey(RightListBox.Items[index].Value.Trim()))
         {
             BaseItems.Add(RightListBox.Items[index].Value.Trim(), RightListBox.Items[index].Text.Trim());
         }
     }
 }
Esempio n. 2
0
        // Reload list items from the data source.
        private void LoadItemsFromSource()
        {
            // Tell the control not to bother redrawing until we're done
            // adding new items - avoids flicker and speeds things up.
            BeginUpdate();

            try
            {
                // We're about to rebuild the list, so get rid of the current
                // items.
                //Items.Clear();
                BaseItems.Clear();

                // m_bindingList won't be set if the data source doesn't
                // implement IBindingList, so always ask the CurrencyManager
                // for the IList. (IList is all we need to retrieve the rows.)

                IList items = m_currencyManager.List;

                // Add items to list.
                int nItems = items.Count;
                for (int i = 0; i < nItems; ++i)
                {
                    //Items.Add(BuildItemForRow(items[i]));
                    //BaseItems.Add(BuildItemForRow(items[i]));
                    BuildItemForRow(items[i]);
                }
                int index = m_currencyManager.Position;
                if (index != -1)
                {
                    SetSelectedIndex(index);
                }
            }
            finally
            {
                // In finally block just in case the data source does something
                // nasty to us - it feels like it might be bad to leave the
                // control in a state where we called BeginUpdate without a
                // corresponding EndUpdate.
                EndUpdate();
            }
        }
Esempio n. 3
0
        public void ResetItems(bool clear)
        {
            ComboBox control = BaseValueControl as ComboBox;

            if (control == null)
            {
                return;
            }
            if (clear)
            {
                BaseItems.Clear();
            }

            List <object> cbItems = new List <object>();

            foreach (var item in Items)
            {
                cbItems.Add(string.Format("{0}", item));
            }

            Form.SetComboBoxItems(control, Items.IndexOf(Value), cbItems.ToArray());
        }
Esempio n. 4
0
 public void Clear()
 {
     BaseItems.Clear();
 }