public object Clone() { ComboBoxColumn clone = new ComboBoxColumn(); foreach (PropertyInfo property in this.GetType().GetProperties()) { PropertyInfo cloneProperty = clone.GetType().GetProperty(property.Name); cloneProperty.SetValue(clone, property.GetValue(this, null), null); } return(clone); }
private void bSubir_Click(object sender, EventArgs e) { if (bs.Position == 0) { return; } ComboBoxColumn col1 = ((ComboBoxColumn)bs.Current).Clone() as ComboBoxColumn; ComboBoxColumn col2 = ((ComboBoxColumn)bs[bs.Position - 1]).Clone() as ComboBoxColumn; bs[bs.Position - 1] = col1; bs[bs.Position] = col2; bs.Position--; }
private void bBajar_Click(object sender, EventArgs e) { if (bs.Position == bs.Count - 1) { return; } ComboBoxColumn col1 = ((ComboBoxColumn)bs.Current).Clone() as ComboBoxColumn; ComboBoxColumn col2 = ((ComboBoxColumn)bs[bs.Position + 1]).Clone() as ComboBoxColumn; bs[bs.Position + 1] = col1; bs[bs.Position] = col2; bs.Position++; }
private void listBox1_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index < 0) { return; } ComboBoxColumn column = (ComboBoxColumn)this.bs[e.Index]; ControlPaint.DrawButton(e.Graphics, new Rectangle(0, e.Bounds.Y + ((e.Bounds.Height - 20) / 2), 20, 20), ButtonState.Normal); e.Graphics.DrawString(e.Index.ToString(), this.listBox1.Font, Brushes.Black, new Rectangle(0, e.Bounds.Y + ((e.Bounds.Height - 20) / 2), 20, 20), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); Color backColor = (e.State & DrawItemState.Focus) > 0 || (e.State & DrawItemState.Selected) > 0 ? SystemColors.Highlight : SystemColors.Window; Color foreColor = (e.State & DrawItemState.Focus) > 0 || (e.State & DrawItemState.Selected) > 0 ? SystemColors.HighlightText : SystemColors.ControlText; e.Graphics.FillRectangle(new SolidBrush(backColor), new Rectangle(22, e.Bounds.Y, e.Bounds.Width - 22, e.Bounds.Height)); TextRenderer.DrawText(e.Graphics, string.Format("{0} (\"{1}\")", column.Caption, column.FieldName), this.listBox1.Font, new Rectangle(22, e.Bounds.Y, e.Bounds.Width - 22, e.Bounds.Height), foreColor, TextFormatFlags.WordEllipsis | TextFormatFlags.VerticalCenter); //e.Graphics.DrawString(string.Format("{0} (\"{1}\")", column.Caption, column.FieldName), this.listBox1.Font, new SolidBrush(foreColor), new Rectangle(22, e.Bounds.Y, e.Bounds.Width - 22, e.Bounds.Height), new StringFormat() { LineAlignment = StringAlignment.Center }); }
public int Add(ComboBoxColumn column) { return(this.List.Add(column)); }