private void AddCheckBoxToPanel(string s, int i) { if (panel1.InvokeRequired == true) { PanelCallback d = new PanelCallback(AddCheckBoxToPanel); this.Invoke(d, s, i); } else { Label label = new Label(); label.Location = new Point(10, 15 + i * 30); label.Text = string.Format("第{0}桌:", i + 1); label.Width = 70; this.panel1.Controls.Add(label); CreateCheckBox(i, 0, s, "黑方"); CreateCheckBox(i, 1, s, "白方"); } }
private void AddCheckBoxToPanel(string s, int i)//添加一行 { if (panel1.InvokeRequired == true) { PanelCallback d = new PanelCallback(AddCheckBoxToPanel); this.Invoke(d, s, i); } else { Label label = new Label(); label.Location = new Point(10, 15 + i * 30); label.Text = string.Format("第{0}桌:", i + 1); label.Width = 70; this.panel1.Controls.Add(label); for (int j = 0; j < MAX_USER; j++) { int x = 100 + j * 60; CheckBoxGameTables[i, j] = new CheckBox(); CheckBoxGameTables[i, j].Name = string.Format("check{0:0000}{1:0000}", i, j); CheckBoxGameTables[i, j].Width = 60; CheckBoxGameTables[i, j].Location = new Point(x, 10 + i * 30); CheckBoxGameTables[i, j].Text = string.Format("座位{0}", j + 1); CheckBoxGameTables[i, j].TextAlign = ContentAlignment.MiddleLeft; if (s[MAX_USER * i + j] == '1') { CheckBoxGameTables[i, j].Enabled = false; CheckBoxGameTables[i, j].Checked = true; } else { CheckBoxGameTables[i, j].Enabled = true; CheckBoxGameTables[i, j].Checked = false; } this.panel1.Controls.Add(CheckBoxGameTables[i, j]); CheckBoxGameTables[i, j].Click += new EventHandler(checkBox_Click); } } }