private void PrintingSystem_EditingFieldChanged(object sender, DevExpress.XtraPrinting.EditingFieldEventArgs e)
{
var brick = e.EditingField.Brick;
if (brick.BrickOwner is XRLabel)
{
((XRLabel)brick.BrickOwner).Text = brick.Text;
}
else if (brick.BrickOwner is XRCheckBox)
{
var chk = (XRCheckBox)brick.BrickOwner;
var name = chk.Tag?.ToString();
if (!string.IsNullOrEmpty(name))
{
var ctl = ReportHeader.Controls.Cast<XRControl>().FirstOrDefault(c => c.Name == name);
if (!string.IsNullOrEmpty(chk.EditOptions.GroupID))
{
//单选
ctl.Tag = brick.Text;
}
else
{
//多选
var arr = string.IsNullOrEmpty(ctl.Tag?.ToString()) ? new List<string>() : ctl.Tag?.ToString().Split('&').ToList();
if (!string.IsNullOrEmpty(chk.Text))
{
{
var brick = e.EditingField.Brick;
if (brick.BrickOwner is XRLabel)
{
((XRLabel)brick.BrickOwner).Text = brick.Text;
}
else if (brick.BrickOwner is XRCheckBox)
{
var chk = (XRCheckBox)brick.BrickOwner;
var name = chk.Tag?.ToString();
if (!string.IsNullOrEmpty(name))
{
var ctl = ReportHeader.Controls.Cast<XRControl>().FirstOrDefault(c => c.Name == name);
if (!string.IsNullOrEmpty(chk.EditOptions.GroupID))
{
//单选
ctl.Tag = brick.Text;
}
else
{
//多选
var arr = string.IsNullOrEmpty(ctl.Tag?.ToString()) ? new List<string>() : ctl.Tag?.ToString().Split('&').ToList();
if (!string.IsNullOrEmpty(chk.Text))
{
if (false == arr.Exists(i => i.Equals(chk.Text, System.StringComparison.OrdinalIgnoreCase)))
{
//集合没有,并勾选了
if (e.EditingField.EditValue.ToString() == "Checked")
arr.Add(chk.Text);
}
else
{
if (e.EditingField.EditValue.ToString() == "Unchecked")
{
arr.Remove(chk.Text);
}
}
}
ctl.Tag = string.Join("&", arr);
}
}
}
}
{
//集合没有,并勾选了
if (e.EditingField.EditValue.ToString() == "Checked")
arr.Add(chk.Text);
}
else
{
if (e.EditingField.EditValue.ToString() == "Unchecked")
{
arr.Remove(chk.Text);
}
}
}
ctl.Tag = string.Join("&", arr);
}
}
}
}
radiobutton用checkbox来代替
对于多个checkbox只要选一个的情况,设置每个checkbox的tag值为同一个控件,并且设置checkbox的EditOpitions.GroupID不为空。
多于多个checkbox需要选多个的情况,设置每个checkbox的tag值为同一个控件。