示例#1
0
 private void UpdateCmbVals()
 {
     cmbVals.SuspendLayout();
     cmbVals.Items.Clear();
     foreach (RcVal v in vallist.List)
     {
         cmbVals.Items.Add(v);
     }
     cmbVals.Items.Add("(Val編集...)");
     cmbVals.ResumeLayout();
 }
        public static ComboBox ComboBox(Parts.Attribute attribute, string[] items, ToolTip tooltip = null)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(attribute.Name) || items.Length == 0)
                {
                    throw new ArgumentNullException();
                }
                var comboBox = new ComboBox();
                comboBox.SuspendLayout();
                comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
                comboBox.ForeColor = System.Drawing.Color.Black;
                comboBox.FlatStyle = FlatStyle.Flat;
                comboBox.Font = Methods.BaseFont;
                comboBox.FormattingEnabled = true;
                comboBox.Name = "cb" + attribute.Name;
                comboBox.Size = new System.Drawing.Size(121, 21);
                comboBox.Items.AddRange(items);
                comboBox.Tag = attribute;

                if (String.IsNullOrWhiteSpace(attribute.Value))
                {
                    comboBox.SelectedIndex = comboBox.Items.IndexOf(attribute.Default);
                }
                else
                {
                    comboBox.SelectedIndex = comboBox.Items.IndexOf(attribute.Value);
                }

                if (tooltip != null)
                {
                    tooltip.SetToolTip(comboBox, attribute.Documentation);
                }

                comboBox.ResumeLayout();
                return comboBox;
            }
            catch (Exception ex)
            {
                log.Debug(ex);
                return null;
            }
        }
示例#3
0
        protected override void OnLoad(EventArgs e)
        {
            // Initialize the album
            _album = new PhotoAlbum();

            // Initialize the combo box
            cmbxAlbums.SuspendLayout();
            foreach (string s in Directory.GetFiles(PhotoAlbum.DefaultDir, "*.abm"))
            {
                cmbxAlbums.Items.Add(s);
            }
            cmbxAlbums.ResumeLayout();

            if (cmbxAlbums.Items.Count > 0)
            {
                cmbxAlbums.SelectedIndex = 0;
            }

            base.OnLoad(e);
        }
示例#4
0
 public static void PopulateComboBox(ComboBox comboBox, List<string> items)
 {
     comboBox.SuspendLayout();
     comboBox.Items.Clear();
     foreach(string item in items)
     {
         comboBox.Items.Add(item);
     }
     comboBox.ResumeLayout();
     comboBox.SelectedIndex = 0;
 }