示例#1
0
 public void InitializeArrayList(ArrayList list)
 {
     if ((list == null) || (list.Count < 1))
     {
         throw new Exception("List not Initialized.");
     }
     this.list             = list;
     listBox.DataSource    = list;
     listBox.DisplayMember = "Name";
     listBox.ValueMember   = "Value";
     max = -2147483648;
     min = 0x7fffffff;
     for (int i = 0; i < list.Count; i++)
     {
         SelectBoxItem item = (SelectBoxItem)list[i];
         int           num2 = item.Value;
         if (max < num2)
         {
             max = num2;
         }
         if (min > num2)
         {
             min = num2;
         }
     }
 }
示例#2
0
 public string SearchByValue(int value)
 {
     for (int i = 0; i < list.Count; i++)
     {
         SelectBoxItem item = (SelectBoxItem)list[i];
         if (value == item.Value)
         {
             return(item.Name);
         }
     }
     return(string.Empty);
 }
示例#3
0
 public int SearchByName(string name)
 {
     for (int i = 0; i < list.Count; i++)
     {
         SelectBoxItem item = (SelectBoxItem)list[i];
         if (name.Equals(item.Name))
         {
             return(item.Value);
         }
     }
     return(-1);
 }