如何为绑定到 List的 dataGridView 设置列名称?
如下所示,我创建了一个装备列表。我想让列名称更具描述性 - 是否有我可以在装备.属性中使用的属性?
DataGridView.Datasource = EquipList;
List<equip> EquipList = new List<equip>();
public class equip
{
public int EquipID {get;set;}
public string EquipName {get;set;}
}
好吧,也许我没有正确解释自己...我希望有一个属性可以应用,例如...
[Alis("name I would like to see in the gridview")]
public int EquipID {get;set;}
坚持使用旧的疲惫方式
如果没有,我会在当天早上晚些时候 ... ..
我得到了它!
using System.ComponentModel;
[DisplayName("the nice name")]
public int EquipID {get;set;}
As shown below I have created a List of equip.I would like to have the column names more descriptive - is there an attribute that I can use in the equip.properties?
DataGridView.Datasource = EquipList;
List<equip> EquipList = new List<equip>();
public class equip
{
public int EquipID {get;set;}
public string EquipName {get;set;}
}
Okay, maybe I didn't explain myself properly...I am hoping that that there is an attribute that could be applied like....
[Alis("name I would like to see in the gridview")]
public int EquipID {get;set;}
if not I'll just stick with the old tired ways
Later on that same morning....
I got it!
using System.ComponentModel;
[DisplayName("the nice name")]
public int EquipID {get;set;}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这有效..
如下:类中的前两个属性将显示为
使用新名称后,第三个属性将不会按照
可浏览属性。
This works..
below:the first two properties in the class will be displayed with
with their new names, the third property will not display as per the
Browsable attribute.
您可以尝试一下,
使用 Designer 可以轻松实现这一点。
You can try this
You can achieve this easily with Designer.