• XtraReport中使用Checkbox控件来代替radioButton的单选和复选功能


     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))
                            {
                                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);
                        }
                    }
                }
            }
     
    radiobutton用checkbox来代替
    对于多个checkbox只要选一个的情况,设置每个checkbox的tag值为同一个控件,并且设置checkbox的EditOpitions.GroupID不为空。
    多于多个checkbox需要选多个的情况,设置每个checkbox的tag值为同一个控件。
  • 相关阅读:
    线程中死锁的demo
    发布.net core程序碰到的问题
    .net core Identity学习(三) 第三方认证接入
    .net Identity学习(二)OAuth
    .net core Identity学习(一)注册登录
    Git常用操作
    log4net使用
    c#中的Quartz
    jquery中的deferred
    .net core应用部署在IIS上
  • 原文地址:https://www.cnblogs.com/yslgg/p/13904173.html
Copyright © 2020-2023  润新知