Exemplo n.º 1
0
 public int GetIndex(DropDownListItem item)
 {
     if (this.ucItemPanel.Controls.Contains(item))
     {
         return(this.ucItemPanel.Controls.GetChildIndex(item));
     }
     return(-1);
 }
Exemplo n.º 2
0
 /// <summary>
 /// 删除一项
 /// </summary>
 /// <param name="item"></param>
 public void Remove(DropDownListItem item)
 {
     if (this.ucItemPanel.Controls.Contains(item))
     {
         this.ucItemPanel.Controls.Remove(item);
         item.Click -= new EventHandler(DropDownListItem_Click);
     }
 }
Exemplo n.º 3
0
        void DropDownListItem_Click(object sender, EventArgs e)
        {
            DropDownListItem currentItem = sender as DropDownListItem;

            if (ItemClicked != null)
            {
                ItemClicked(this, currentItem);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 增加一项
 /// </summary>
 /// <param name="item"></param>
 public void Add(DropDownListItem item)
 {
     if (!this.ucItemPanel.Controls.Contains(item))
     {
         this.ucItemPanel.Controls.Add(item);
         this.ucItemPanel.Controls.SetChildIndex(item, this.ucItemPanel.Controls.Count - 1);
         if (_linkedControl != null)
         {
             item.ForeColor = _linkedControl.ForeColor;
         }
         item.Click += new EventHandler(DropDownListItem_Click);
     }
 }
Exemplo n.º 5
0
        private void SetSelectedValue(DropDownListItem value)
        {
            bool hasChanged   = selectedItem != value;
            var  previousItem = selectedItem;

            selectedItem = value;

            if (hasChanged)
            {
                if (selectedItem == null)
                {
                    this.Text = string.Empty;
                }
                else
                {
                    this.Text = selectedItem.Text;
                }

                if (this.SelectionChanged != null)
                {
                    SelectionChanged(this, previousItem, selectedItem);
                }
            }
        }
Exemplo n.º 6
0
 void frmDropDownList_ItemClicked(object sender, DropDownListItem e)
 {
     this.SelectedItem = e;
     this.frmDropDownList.Hide();
 }
Exemplo n.º 7
0
 public bool Contains(DropDownListItem item)
 {
     return(this.ucItemPanel.Controls.Contains(item));
 }