المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Form controls data binding sequence



C# Programming
05-24-2010, 07:20 PM
I'm developing a databound desktop application. On one particular form, I have two list controls -- call them list A and list B. The choices of list B are directly dependent on the selection made in list A. When creating a new record, this is all fine. I make a selection in list A, and the SelectionChanged event triggers a repopulation of the options in list B.

The problem comes in on loading a record from a database. Even though I can see the related fields for the A and B selections both have legit data, a list B selection is not being made at data-binding time. Step tracing shows me that .NET is attempting to bind the list B selection first. Since no A selection has been made at that point, the data source for list B is null, and so no selection is made.

These "lists" are custom controls, so I could kludge it and put in a "memorized" value that retroactively makes the selection once the control's data source is not null. But that seems like really bad practice. Is there a way to set the sequence of individual control data binding at the form level?