Problem with custom binding

I have a UserControl which have many instances of another UserControl as a child controls.

I am trying to databind Properties in the child controls to a dataview. The problem is i get the same data in the all the child controls even though i am iterating using currency manager. here is what i am doing. Can someone help

public void AddJobDataView(DataView dv)

{

int Y = this.Header.Height;

this.Header.Size = new Size(this.Width, Y);

this.Footer.Size = new Size(this.Width, this.Footer.Height);

CurrencyManager cm = (CurrencyManager)this.BindingContext[dv];

while (cm.Position < cm.Count)

{

JobListItem item = new JobListItem(); <-- This is the Child Control

item.Job.DataBindings.Add("Id", dv, "ID");

item.Job.DataBindings.Add("ChangedTime", dv, "LastUpdatedTime");

item.Job.DataBindings.Add("LastStatus", dv, "Last Result");

item.Job.DataBindings.Add("Role", dv, "JobExecutionType");

//item.Job.DataBindings.Add("Suite", dv, "Suite");

item.Job.DataBindings.Add("Title", dv, "Name");

item.Job.DataBindings.Add("Priority", dv, "Priority");

item.Job.DataBindings.Add("Owner", dv, "Owner");

item.Location = new Point(0, Y);

//Update the height of the Collection

Y += item.Height + 1;

this.Height = Y + 10;

//Push the footer down

this.Footer.Location = new Point(0, Y);

//Add the item to the collection

this.Controls.Add(item);

if (cm.Position == cm.Count - 1) break;

cm.Position++;

}

}



Answer this question

Problem with custom binding

  • dmelfi

    Nevermind. I figured it out myself. it was a matter of currency manager not being positioned properly for the child controls.
  • Jonathon Howey

    Anybody
  • Problem with custom binding