private void btnOK_Click(object sender, EventArgs e) { StringBuilder sbt = new StringBuilder(); foreach (var m in pnl.Controls) { if (m is CheckBox) { CheckBox cb = (CheckBox)m; if (cb.Checked) { sbt.AppendFormat("|{0}", cb.Tag); } } } if (sbt.Length > 0) { sbt.Remove(0, 1); } IsysService service = sysService.GetService(); service.AddRoleMenu(roleID, sbt.ToString()); DialogResult = DialogResult.OK; }