예제 #1
0
 public void UpdateValueItems(GXDLMSObject target, int index)
 {
     if (InvokeRequired)
     {
         this.BeginInvoke(new UpdateValueItemsEventHandler(UpdateValueItems), target, index);
     }
     else
     {
         GXDLMSAttributeSettings tmp = GXDLMSClient.GetAttributeInfo(target, index);
         if (tmp != null)
         {
             Items = tmp.Values;
         }
         else
         {
             Items = null;
         }
         if (this.Type == GXValueFieldType.TextBox)
         {
             this.Type = Items == null || Items.Count == 0 ? GXValueFieldType.TextBox : GXValueFieldType.CompoBox;
         }
         comboBox1.Items.Clear();
         if (Items != null)
         {
             foreach (GXObisValueItem it in Items)
             {
                 comboBox1.Items.Add(it.UIValue);
             }
         }
         ReadOnly = (target.GetAccess(index) & Gurux.DLMS.AccessMode.Write) == 0;
     }
 }
예제 #2
0
 public void UpdateValueItems(GXDLMSObject target, int index, object value)
 {
     if (InvokeRequired)
     {
         this.BeginInvoke(new UpdateValueItemsEventHandler(UpdateValueItems), target, index, value);
     }
     else
     {
         GXDLMSAttributeSettings tmp = GXDLMSClient.GetAttributeInfo(target, index);
         if (tmp != null)
         {
             Items = tmp.Values;
         }
         else
         {
             Items = null;
         }
         if (this.Type == GXValueFieldType.TextBox)
         {
             this.Type = Items == null || Items.Count == 0 ? GXValueFieldType.TextBox : GXValueFieldType.CompoBox;
         }
         else if (this.Type == GXValueFieldType.CompoBox)
         {
             comboBox1.Items.Clear();
             if (Items != null && Items.Count != 0)
             {
                 foreach (GXObisValueItem it in Items)
                 {
                     comboBox1.Items.Add(it.UIValue);
                 }
             }
             else if (value is Enum)
             {
                 foreach (var it in Enum.GetValues(value.GetType()))
                 {
                     comboBox1.Items.Add(it);
                 }
             }
         }
         else if (this.Type == GXValueFieldType.ListBox)
         {
             listBox1.Items.Clear();
             if (value is Enum)
             {
                 foreach (var it in Enum.GetValues(value.GetType()))
                 {
                     listBox1.Items.Add(it);
                 }
             }
         }
         else if (this.Type == GXValueFieldType.CheckedListBox)
         {
             checkedlistBox1.Items.Clear();
             if (value is Enum)
             {
                 foreach (var it in Enum.GetValues(value.GetType()))
                 {
                     checkedlistBox1.Items.Add(it);
                 }
             }
         }
         ReadOnly = (target.GetAccess(index) & AccessMode.Write) == 0;
     }
 }