private void SetSelected(EntityStatus entityStatus) { if (!cbStatus.Items.Contains(entityStatus.ToString())) { throw new InvalidDataException($"Unexpected value {entityStatus} passed"); } EntityStatus = entityStatus; cbStatus.SelectedIndex = cbStatus.Items.IndexOf(entityStatus.ToString()); }
public ChangeStatusForm(string entityName, string entityType, EntityStatus desiredStatus) { InitializeComponent(); if (desiredStatus == EntityStatus.Active) { lblMessage.Text = string.Format(EnableFormat, entityType ?? Unknown, entityName ?? Unknown); } else if (desiredStatus == EntityStatus.Disabled) { lblMessage.Text = string.Format(DisableFormat, entityType ?? Unknown, entityName ?? Unknown); } else { lblMessage.Text = string.Format(SetStatusFormat, entityType ?? Unknown, entityName ?? Unknown, desiredStatus.ToString()); } Width = lblMessage.Width + 72; }