controls binding

dubem1

Newcomer
Joined
Dec 5, 2002
Messages
20
Hello,

I have a list of employee in a listview, when I click on an employee, I get this employee form the database, the employee info is then in the dataEmployee class. This class have some properties to get the info. And a control associated to each property.

Each time I click on an employee in the listview, I get the employee I want to show is first name and last name in textbox.
I could do txtLastName.Text = dataEmploye.LName and if I change the value in the textbox I have t do the inverse dataEmploye.Lname = txtLastName.Text

I would like to use the bindings to avoind this manupulation.

So when I click on a employee in the listview I do :

dataEmployee = Employe.Get(idEmployee)

txtLastName.DataBindings.Clear();
txtLastName.DataBindings.Add(new Binding("Text",dataEmployee,"Lname"));

txtFirstName.DataBindings.Clear();
txtFirstName.DataBindings.Add(new Binding("Text",dataEmployee"Fname"));

But I found annoying to redo the bindings each time!! Someone knows a way to do the bindings only once and when I get a new employee, the form is refresh automaticly with the new data?



Thank you
 
Back
Top