BindingSource.Find with no column name

I’ve got a BindingSource as DataSource for a ComboBox. The BindingSource’s source data is a List<String> which obviously doesn’t have column names, but only a list of strings. The BindingSource.Find method expects a column name to search on, so I cannot simply use this function. I need to set the ComboBox to a specific selected item and since the source data is a BindingSource, I think it would be best to work with the BindingSource to achieve my goal.

How can I set the correct item in the BindingSource by finding on a specific string value?

Code example:

readonly List<String> _metaList = new List<String>();

...

while (reader.Read())
{
    _metaList.Add(reader.GetString(0));
}

comboBoxPartities.DataSource = new BindingSource(_metaList, null);
comboBoxPartities.DisplayMember = "Key";

And later on, I need to achieve something like this:

var bs = (BindingSource) comboBoxPartities.DataSource;
var i = bs.Find("?!!", lastProcessedTable);
((BindingSource) comboBoxPartities.DataSource).Position = i;


Download bindingsource.find.with.no.column.name.zip
Direct Link


Download


Download bindingsource.find.with.no.column.name.zip
Mediafire


Download


Download bindingsource.find.with.no.column.name.zip
Anafile


Download


Download bindingsource.find.with.no.column.name.zip
Ultrafile


Download


Download bindingsource.find.with.no.column.name.zip
Sanshare


Download

Both comments and pings are currently closed.

Comments are closed.