Need filling four combo with same DataView

  • Thread starter Thread starter Chakravarti Mukesh
  • Start date Start date
C

Chakravarti Mukesh

Hi,
I have a form with four Combo whose DataSource and DisplayMember is the
same. The problem is that when I select a value from a combo all other
combo start displaying same value. I have not used any
BindingContextManager on the form. (I am using C#)
Thanks
 
Hi,

Chakravarti Mukesh said:
Hi,
I have a form with four Combo whose DataSource and DisplayMember is the
same. The problem is that when I select a value from a combo all other
combo start displaying same value. I have not used any
BindingContextManager on the form. (I am using C#)

* If you are using NET2.0, then set a different BindingSource between them:

ComboBox1.DataSource = new BindingSource(dv,"");
ComboBox2.DataSource = new BindingSource(dv,"");
etc....

* If you are using NET1.1, then there are a few options :
1. Use a different DataView of the same DataTable for each ComboBox:
ComboBox1.DataSource = new DataView( someTable );
ComboBox2.DataSource = new DataView( someTable );

2. Use a different BindingContext, i don't recommend this option because it
_will cause problems_ when you also bind the ComboBox's Text,
SelectedValue, etc to another DataTable.

ComboBox1.BindingContext = new BindingContext();
ComboBox1.DataSource = dv,

ComboBox2.BindingContext = new BindingContext();
ComboBox2.DataSource = dv,

3. Create a simple ListWrapper:

public class ListWrapper : IListSource
{
private IList list;
public ListWrapper( IList List )
{
list = List;
}

public bool ContainsListCollection
{
get { return false; }
}

public IList GetList()
{
return list;
}
}

ComboBox1.DataSource = new ListWrapper( dv );
ComboBox2.DataSource = new ListWrapper( dv );


HTH,
Greetings
 
Back
Top