// TODO: 首次设置颜色也尽量调用 SetLineColor() 实现,这样可以共享代码,减少多处修改带来的麻烦 public EasyLine(EasyMarcControl container) { this.Container = container; // int nTopBlank = (int)this.Container.Font.GetHeight() + 2; label_color = new Label(); label_color.Dock = DockStyle.Fill; label_color.Size = new Size(6, 23); label_color.Margin = new Padding(0, 0, 0, 0); label_color.ImageList = this.Container.ImageListIcons; label_color.ImageIndex = -1; label_color.BackColor = this.Container.LeftBackColor; label_caption = new Label(); label_caption.Dock = DockStyle.Fill; label_caption.Size = new Size(6, 23); label_caption.AutoSize = true; label_caption.Margin = new Padding(4, 6, 4, 4); // new Padding(4, 2, 4, 0) label_caption.TextAlign = ContentAlignment.TopLeft; // label_caption.BackColor = SystemColors.Control; label_caption.BackColor = Color.Transparent; // label_caption.ForeColor = this.Container.ForeColor; splitter = new TransparentSplitter(); // splitter.Dock = DockStyle.Fill; splitter.Size = new Size(8, 23); splitter.Width = 8; splitter.Margin = new Padding(0, 0, 0, 0); splitter.BackColor = Color.Transparent; // 字段/子字段内容 this.textBox_content = new AutoHeightTextBox(); textBox_content.Multiline = true; textBox_content.WordWrap = true; textBox_content.BorderStyle = BorderStyle.None; textBox_content.Dock = DockStyle.Fill; textBox_content.MinimumSize = new Size(20, 21); // 23 textBox_content.Size = new Size(20, 21); // 23 textBox_content.Margin = new Padding(8, 6, 0, 2); // new Padding(8, 4, 0, 0) // textBox_content.BackColor = Color.Red; if (this.Container.BackColor != Color.Transparent) textBox_content.BackColor = this.Container.BackColor; else textBox_content.Tag = textBox_content.BackColor; textBox_content.ForeColor = this.Container.ForeColor; }
internal List<Control> RemoveControls() { AddEvents(false); List<Control> controls = new List<Control>(); controls.Add(this.label_color); this.label_color = null; controls.Add(label_caption); label_caption = null; controls.Add(splitter); splitter = null; controls.Add(textBox_content); textBox_content = null; return controls; }