1
votes

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.

1
As you only have one column, can't you use the ListView? - Felipe Sabino
Yes, you are right too. I think I started using the Datagrid because originally I did have multiple columns, but then returned it back to a single column but didn't look into changing my control... - Jason

1 Answers

1
votes

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