Is there a way to determine the order of columns displayed in a datagridview when bound to a data source contains the underlying IList? I thought that for this there is a certain attribute of the property but can’t remember what it really was.
eg:
public void BindToGrid(IList<CustomClass> list)
{
_bindingSource.DataSource = list;
dataGridView1.DataSource = _bindingSource.DataSource;
}
The type bound should be something like this
class CustomClass
{
bool _selected = false;
public bool Selected
{
get { return _selected; }
set { _selected = value; }
}
string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
string _value;
public string Value
{
get { return _value; }
set { _value = value; }
}
}
Edit: I would like to add that I do not want to add columns manually to the list of columns in the designer. I would like to keep this as dynamic as possible.
source
share