zoukankan      html  css  js  c++  java
  • 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值为同一个控件。
  • 相关阅读:
    ASCII码详解
    C#中判断上传类型为Excel,03和07版的链接字符串
    文本搜索工具的制作过程之搜索
    文本搜索工具之显示
    用C#实现十六进制字符串转换为ASCII
    7个秘诀 工作效率和薪水都翻倍
    C#委托
    VB的写法,关于版本写入注册表
    k8s 集群灾难恢复 k8s
    k8s 接合阿里云负载均衡 k8s
  • 原文地址:https://www.cnblogs.com/yslgg/p/13904173.html
Copyright © 2011-2022 走看看