I have this definition in a WinForm:
private Bin开发者_开发知识库dingList<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.
You could use a simple wrapper class
class Foo
{
public string SomeProperty {get; set;}
}
and use
private BindingList<Foo> rollbackLog = new BindingList<Foo>();
and set DataPropertyName
to "SomeProperty"
.
精彩评论