本文介绍了如何在c#中设置PropertyGrid项的长度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 例如我有1个项目:如何设置Item1 = 80最大长度的最大长度 [类别( All )] [Description(Name)] [ReadOnly(false)] [DisplayName(sPropName)] [XmlAttribute] public 覆盖字符串标签 { get { return base.Label; } set { value = value.TrimEnd(); ignorieren if (value.length> 80 ) { //这里我要用户 不 to 允许 写入超过 80 char 当 用户写一些 in 名称feild max Length 80 我想要用户 允许 } } } 解决方案 For Strings http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.stringlengthattribute.aspx [ ^ ] 对于整数 http: //msdn.microsoft.com/en-us/library/system.configuration.integervalidatorattribute.aspx [ ^ ] // 将第3列的大小设置为250 此 .gridDataBoundGrid1 .AllowResizeToFit = false ; 此 .gridDataBoundGrid1.Model.ColWidths [ 3 ] = 250 For example I have 1 item: How can I set max length for Item1 = 80 max length[Category(All)] [Description(Name)] [ReadOnly(false)] [DisplayName(sPropName)] [XmlAttribute] public override string Label { get { return base.Label; } set { value = value.TrimEnd(); ignorieren if (value.length > 80) { //here I want user not to allow to write more than 80 char when user write something in Name feild max Length 80 i want a user to allow } } } 解决方案 For Stringshttp://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.stringlengthattribute.aspx[^]For Integers http://msdn.microsoft.com/en-us/library/system.configuration.integervalidatorattribute.aspx[^]//set size of column 3 to 250this.gridDataBoundGrid1.AllowResizeToFit = false;this.gridDataBoundGrid1.Model.ColWidths[3] = 250; 这篇关于如何在c#中设置PropertyGrid项的长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-24 06:56