DataGridView 列绑定到字符串
我在 WinForm 中有这样的定义:
private BindingList<String> rollbackLog = new BindingList<String>();
我有一个带有单个列的 DataGridView,我想将该列绑定到此列表。我遇到的问题是我不知道要为列的 DataPropertyName 属性分配什么。即,我不认为“string”的属性会返回值?
我是否必须使用字符串属性定义自己的类,然后从中读取?
考虑到我只有一个属性,使用 ListBox 将是首选选项,但这最终更出于兴趣。
I have this definition in a WinForm:
private BindingList<String> rollbackLog = new BindingList<String>();
I have a DataGridView with a single column and I want to bind that column to this list. The issue I have is I don't know what to assign to the DataPropertyName property of the column. ie, I don't think there's a property of "string" which will return the value?
Do I have to define my own class with a string property and then read from that?
Using a ListBox would be the preferred option given I have only a single property, but this is more out of interest in the end.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用一个简单的包装类
,并使用
并将
DataPropertyName
设置为"SomeProperty"
。You could use a simple wrapper class
and use
and set
DataPropertyName
to"SomeProperty"
.