[英]How to hide DataGridView Column?
i have a simple class like below. 我有一个简单的类,如下所示。 And a
List<Person>
. 还有一个
List<Person>
。 I bind this list to the DataGridView
in the Form. 我将此列表绑定到Form中的
DataGridView
。
class Person {
public int ID {get; set;}
public string Name { get; set; }
public string Surname { get; set; }
[DisplayName("Birth Date")]
public DateTime BDate { get; set; }
}
With Attribute DisplayName
i can change column header text. 使用属性
DisplayName
我可以更改列标题文本。
My question is 我的问题是
Is there any Attribute to hide the ID
Property of the Person
? 是否有任何属性可以隐藏
Person
的ID
属性?
AND SECOND QUESTION (UPDATED) 和第二个问题(更新)
Is there any Attribute to change the order of this properties when bind the list to the grid? 将列表绑定到网格时,是否有任何属性可以更改此属性的顺序?
You can use: [Browsable(false)] 您可以使用:[Browsable(false)]
class Person {
[Browsable(false)]
public int ID {get; set;}
public string Name { get; set; }
public string Surname { get; set; }
[DisplayName("Birth Date")]
public DateTime BDate { get; set; }
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.