private void FillColorControl_Load(object sender, EventArgs e) { int top = 1; int left = 1; for (int i = 0; i < CP.colorList.Count; i++) { ColorButton b = new ColorButton(i); b.BackColorChanged += b_BackColorChanged; b.BackColor = CP.colorList[i]; b.Top = top; b.Left = left; left += b.Width; if (left + b.Width >= this.panel1.Width) { top += b.Height + 2; left = 1; } this.panel1.Controls.Add(b); } }
void b_BackColorChanged(object sender, EventArgs e) { ColorButton b = sender as ColorButton; this.CP.colorList[b.Index] = b.BackColor; }
private void FillColorControl_Load(object sender, EventArgs e) { ColorButton b = new ColorButton(0); this.panel1.Controls.Add(b); }