protected override void UpdateAllControls()
{
base.UpdateAllControls();
var data = GetCurrentData();
if (element.options != null)
{
int value;
switch (element.type)
{
case ElementValueType.SByte:
case ElementValueType.Byte:
value = (int)TypeConverter.h2sb(data);
break;
case ElementValueType.Short:
case ElementValueType.UShort:
value = (int)TypeConverter.h2ss(data);
break;
case ElementValueType.Int:
case ElementValueType.UInt:
value = TypeConverter.h2si(data);
break;
default:
value = 0;
break;
}
this.cboOptions.Items.Clear();
int idx = -1;
for (int j = 0; j < element.options.Length; j += 2)
{
int cbVal;
if (int.TryParse(element.options[j + 1], out cbVal))
{
this.cboOptions.Items.Add(new comboBoxItem(element.options[j], cbVal));
if (cbVal == value)
{
idx = this.cboOptions.Items.Count - 1;
}
}
}
if (idx < this.cboOptions.Items.Count)
{
this.cboOptions.SelectedIndex = idx;
}
else
{
this.cboOptions.SelectedIndex = -1;
}
}
}