August 19, 2006

Initializing A ComboBox In CE.NET With The Values of An Enum

  SomeEnum status;
  int offset = 0;
  bool defined = false;
  do
  {
      status = (SomeEnum)offset++;
      defined = Enum.IsDefined(typeof(SomeEnum), status.ToString());
      if (defined)
      {
          comboBox.Items.Add(status);
      }

  } while (IsDefined);
  comboBox.SelectedIndex = 0;

No comments: