You could create a BindingList<> object to hold your objects and
then bind that list to the three controls. Then setting the
BindingContexts to different objects would let the 3 controls have
different positions with a single list.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
BindingList<MyObject> list = new BindingList<MyObject>();
list.Add(new MyObject("Ramya", 43));
list.Add(new MyObject("Manju", 43));
list.Add(new MyObject("Gulnus", 43));
list.Add(new MyObject("Sona", 43));
dataGridView1.DataSource = list;
comboBox1.DataSource = list;
comboBox1.DisplayMember = "Name";
comboBox1.ValueMember = "Name";
comboBox2.DataSource = list;
comboBox2.DisplayMember = "Name";
comboBox2.ValueMember = "Name";
comboBox1.BindingContext = new BindingContext();
comboBox2.BindingContext = new BindingContext();
dataGridView1.BindingContext = new BindingContext();
}
}
public class MyObject
{
private string mName;
private int mAge;
public MyObject(string s, int i)
{
mName = s;
mAge = i;
}
public string Name
{
get { return mName; }
set { mName = value; }
}
public int Age
{
get { return mAge; }
set { mAge = value; }
}
public override string ToString()
{
return Name;
}
}