[Browsable(false)]

本文详细解析了C#中[Browsable]属性的作用,特别是[Browsable(false)]如何隐藏对象使其不显示在设计器的属性窗口,以及[Browsable(true)]的应用实例。通过具体代码示例,读者可以深入了解这一特性的使用场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[Browsable(false)]

1.c#方法上面的[Browsable(false)]是干吗用的?

答案:标明此对象不可被浏览,这样它就不会出现在设计器的属性窗口里了

看如下代码:

 

   /// <include file='AspNetPagerDocs.xml' path='AspNetPagerDoc/Property[@name="ImagePath"]/*'/>
        [Browsable(true), Category("Appearance"), ANPDescription("desc_ImagePath"), DefaultValue(null)]
        public string ImagePath{
            get {
                if (null != cloneFrom)
                    return cloneFrom.ImagePath;
                string imgPath = (string)ViewState["ImagePath"];
                if (imgPath != null)
                    imgPath = ResolveUrl(imgPath);
                return imgPath;
            }
            set{
                string imgPath = value.Trim().Replace("\\", "/");
                ViewState["ImagePath"] = (imgPath.EndsWith("/")) ? imgPath : imgPath + "/";
            }
        }

 

///<summary> ///成品库未发货仓储费 ///</summary> [SugarTable("WFHCPK")] public partial class WFHCPK { public WFHCPK() { } /// <summary> /// Description: /// DefaultValue: /// Nullable:False /// <summary> [Browsable(false)] [DisplayName("")] [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public int ID { get; set; } /// <summary> /// Description:受损阿米巴 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("受损阿米巴")] public string SSAMB { get; set; } /// <summary> /// Description:责任阿米巴 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("责任阿米巴")] public string ZRAMB { get; set; } /// <summary> /// Description:生产编号 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("生产编号")] public string ProductionNumber { get; set; } /// <summary> /// Description:生产类型 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("生产类型")] public string ProductType { get; set; } /// <summary> /// Description:生产控制方 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("生产控制方")] public string ProductionControl { get; set; } /// <summary> /// Description:主要加工车间 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("主要加工车间")] public string ProductionWorkshop { get; set; } /// <summary> /// Description:成品入库日期 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("成品入库日期")] public DateTime ReceivingDate { get; set; } /// <summary> /// Description:要求发货日期 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("要求发货日期")] public DateTime DispatchDate { get; set; } /// <summary> /// Description:免费仓储天数 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("免费仓储天数")] public int? FreeDays { get; set; } /// <summary> /// Description:已存储天数 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("已存储天数")] public int? StorageDays { get; set; } /// <summary> /// Description:赔偿金额 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("赔偿金额")] public string Amount { get; set; } /// <summary> /// Description:创建人 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("创建人")] public string Creator { get; set; } /// <summary> /// Description:创建时间 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("创建时间")] public DateTime? CreateTime { get; set; } /// <summary> /// Description:更新人 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("更新人")] public string Updater { get; set; } /// <summary> /// Description:更新时间 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("更新时间")] public DateTime? UpdateTime { get; set; } /// <summary> /// Description:上次记录日期 /// DefaultValue: /// Nullable:True /// <summary> [Browsable(false)] [DisplayName("上次记录日期")] public DateTime LastTime { get; set; } 查看全部 }这是我的一个类 Amount列的格式为202507:3170 \r\n 202508:310 现在获取这个类的数据绑定到gridconrol 想要根据amount列的数据动态拆分添加数据列 202507赔偿 202508赔偿 3170 310
最新发布
07-09
车间生产有一台用电设备 他每次运行24-32小时,开机后后台每十分钟记录一次功率变化,因为一天24小时电价是波动的,现在想要根据一次运行期间记录的功率数据和一天24小时内每小时的电价数据,开发一款自动计算设备最佳开机时间的软件 其中运行时间不是固定的 需要传入参数 提供C#代码其中电价和功率存储在数据中 使用sqlsugar获取 ///<summary> ///区间电价表 ///</summary> [SugarTable("ElectricityPrices")] public partial class ElectricityPrices { public ElectricityPrices() { } /// <summary> /// Description: /// DefaultValue: /// Nullable:False /// <summary> /// [Browsable(false)] [DisplayName("")] [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public int ID { get; set; } /// <summary> /// Description:起始时间 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("起始时间")] public DateTime StartTime { get; set; } /// <summary> /// Description:结束时间 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("结束时间")] public DateTime EndTime { get; set; } /// <summary> /// Description:价格 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("价格")] public decimal? Price { get; set; } }///<summary> ///电炉功率记录表 ///</summary> [SugarTable("PowerData")] public partial class PowerData { public PowerData() { } /// <summary> /// Description: /// DefaultValue: /// Nullable:False /// <summary> /// [Browsable(false)] [DisplayName("")] [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public int ID { get; set; } /// <summary> /// Description:炉号 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("炉号")] public string Lh { get; set; } /// <summary> /// Description:时间 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("时间")] public DateTime Time { get; set; } /// <summary> /// Description:功率 /// DefaultValue: /// Nullable:True /// <summary> /// [Browsable(false)] [DisplayName("功率")] public int? Power { get; set; } }
06-14
``` [Category("检测限定"), Description("深度上限"), Browsable(true), ReadOnly(false)] public double LimitMax { get; set; } = 180; [Category("检测限定"), Description("深度下限"), Browsable(true), ReadOnly(false)] public double LimitMin { get; set; } = 80; [Category("检测限定"), Description("偏位阈值上"), Browsable(true), ReadOnly(false)] public double LimitUp { get; set; } = 180; [Category("检测限定"), Description("偏位阈值下"), Browsable(true), ReadOnly(false)] public double LimitButtom { get; set; } = 80; [Category("检测限定"), Description("偏位阈值左"), Browsable(true), ReadOnly(false)] public double LimitLeft{ get; set; } = 180; [Category("检测限定"), Description("偏位阈值右"), Browsable(true), ReadOnly(false)] public double LimitRight { get; set; } = 80; [Category("检测限定"), Description("每个位置焊坑数量"), Browsable(true), ReadOnly(false)] public double Num { get; set; } = 50; [Category("检测限定"), Description("焊坑OK数量比例下限"), Browsable(true), ReadOnly(false)] public double LimitOKRatio { get; set; } = 0.6; [Category("检测限定"), Description("强制OK"), Browsable(true), ReadOnly(false)] public bool EnforceOK { get; set; } = false; [Category("3D相机参数"), Description("Y向间距/um"), Browsable(true), ReadOnly(false)] public double Yinterval { get; set; } = 33.6; [Category("产品参数"), Description("焊点点位数量"), Browsable(true), ReadOnly(false)] public int PointNum { get; set; } = 60; [Category("结果保存设定"), Description("是否保存原图"), Browsable(true), ReadOnly(false)] public bool SaveRawImage { get; set; } = true; [Category("结果保存设定"), Description("是否保存结果图片"), Browsable(true), ReadOnly(false)] public bool SaveResultImage { get; set; } = true; [Category("结果保存设定"), Description("原图保存路径"), Browsable(true), ReadOnly(false)] public string RawImagePath { get; set; } = "D:\\RawImage"; [Category("结果保存设定"), Description("结果图片保存路径"), Browsable(true), ReadOnly(false)] public string ResultImagePath { get; set; } = "D:\\ResultImage"; [Category("结果保存设定"), Description("结果数据保存路径"), Browsable(true), ReadOnly(false)] public string ResultDataPath { get; set; } = "D:\\ResultData"; ///// <summary> ///// 选择检查哪一种产品 ///// </summary> //[Category("\t型号"), Description("暂定型号(若没有,则报异常):\n0608 \n1202"), Browsable(true), ReadOnly(false)] //public SYRCraft 产品型号 { get; set; } = SYRCraft.Mode01; #region"参数限定" private double _曝光 = 10000; private double _增益 = 1;```解释代码内容
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值