> Dear All,
>
[quoted text clipped - 18 lines]
>
> Cyp Drv.
Hi Kilo,
You can use the same datasource to bind against multiple controls.
List<Employee> employees = new List<Employee>();
employees.Add(new Employee("Jim", "Seattle"));
employees.Add(new Employee("Bill", "New York"));
employees.Add(new Employee("Ann", "Florida"));
dataGridView1.DataSource = employees;
textBox1.DataBindings.Add("Text", employees, "Name");
Note, however, that you may need to use more suitable datasources than
simple lists. Your best bet is to create a BindingSource of the list and
bind against this BindingSource.
List<Employee> employees = new List<Employee>();
employees.Add(new Employee("Jim", "Seattle"));
employees.Add(new Employee("Bill", "New York"));
employees.Add(new Employee("Ann", "Florida"));
BindingSource bs = new BindingSource(employees, "");
dataGridView1.DataSource = bs;
textBox1.DataBindings.Add("Text", bs, "Name");
When using databinding and you need to programmatically add and remove items
from a list, use a BindingList instead of List. If you otherwise change
properties on bound objects, you may also need to use INotifyPropertyChanged
and fire off a PropertyChanged event.
public class Employee : INotifyPropertyChanged
{
private string _name;
private string _address;
public string Name
{
get { return _name; }
set { _name = value; }
}
public string Address
{
get { return _address; }
set
{
if (_address != value)
{
_address = value;
if (PropertyChanged != null)
PropertyChanged(this, new
PropertyChangedEventArgs("Address"));
}
}
}
public Employee(string name, string address)
{
Name = name;
Address = address;
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}

Signature
Happy Coding!
Morten Wennevik [C# MVP]
Kilo - 05 Oct 2008 03:13 GMT
Dear Morten,
Thanks For your Reply.
Regards,
Kilo
>> Dear All,
>>
[quoted text clipped - 88 lines]
> #endregion
> }