开发者

DataGridView column bind to string

开发者 https://www.devze.com 2023-04-11 02:57 出处:网络
I have this definition in a WinForm: private Bin开发者_开发知识库dingList<String> rollbackLog = new BindingList<String>();

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" .

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号