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; } }
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); }
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; }
private void DrawForegroundFromButton(PaintEventArgs pevent) { if (_imageButton == null) { _imageButton = new ComboBox(); //_imageButton.Parent = new TransparentControl(); _imageButton.SuspendLayout(); _imageButton.BackColor = Color.White; //_imageButton.FlatAppearance.BorderSize = 0; _imageButton.FlatStyle = FlatStyle.Flat; } else { _imageButton.SuspendLayout(); } if (Enabled) { _imageButton.ForeColor = ForeColor; } else { _imageButton.ForeColor = Color.FromArgb((3*ForeColor.R + _backColor.R) >> 2, (3*ForeColor.G + _backColor.G) >> 2, (3*ForeColor.B + _backColor.B) >> 2); } _imageButton.Font = Font; _imageButton.RightToLeft = RightToLeft; /* _imageButton.Image = Image; if (Image != null && !Enabled) { Size size = Image.Size; float[][] newColorMatrix = new float[5][]; newColorMatrix[0] = new float[] { 0.2125f, 0.2125f, 0.2125f, 0f, 0f }; newColorMatrix[1] = new float[] { 0.2577f, 0.2577f, 0.2577f, 0f, 0f }; newColorMatrix[2] = new float[] { 0.0361f, 0.0361f, 0.0361f, 0f, 0f }; float[] arr = new float[5]; arr[3] = 1f; newColorMatrix[3] = arr; newColorMatrix[4] = new float[] { 0.38f, 0.38f, 0.38f, 0f, 1f }; System.Drawing.Imaging.ColorMatrix matrix = new System.Drawing.Imaging.ColorMatrix(newColorMatrix); System.Drawing.Imaging.ImageAttributes disabledImageAttr = new System.Drawing.Imaging.ImageAttributes(); disabledImageAttr.ClearColorKey(); disabledImageAttr.SetColorMatrix(matrix); _imageButton.Image = new Bitmap(Image.Width, Image.Height); using (Graphics gr = Graphics.FromImage(_imageButton.Image)) { gr.DrawImage(Image, new Rectangle(0, 0, size.Width, size.Height), 0, 0, size.Width, size.Height, GraphicsUnit.Pixel, disabledImageAttr); } } _imageButton.ImageAlign = ImageAlign; _imageButton.ImageIndex = ImageIndex; _imageButton.ImageKey = ImageKey; _imageButton.ImageList = ImageList; _imageButton.TextAlign = TextAlign; _imageButton.TextImageRelation = TextImageRelation; _imageButton.UseCompatibleTextRendering = UseCompatibleTextRendering; _imageButton.UseMnemonic = UseMnemonic; */ _imageButton.Padding = Padding; _imageButton.Size = Size; _imageButton.Text = Text; _imageButton.ResumeLayout(); InvokePaint(_imageButton, pevent); /* if (_imageButton.Image != null && _imageButton.Image != Image) { _imageButton.Image.Dispose(); _imageButton.Image = null; } */ }