Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
In what method to get data and bind controls?
Message
 
 
À
17/01/2010 10:18:22
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01444346
Message ID:
01444394
Vues:
25
>>Hi,
>>
>>Where do you recommend to make a call to initialize BIZ (typed data set), fill it, and bind controls to the Binding Source? I am reading a book where the examples they have are always in method OnFormLoad. In my tests I use method of the same name as the form class (do I understand correctly that this is equivalent to INIT of VFP?). What is better, OnFormLoad or INIT?
>
>Hi,
>First : There is no WinForms INIT - you probably mean the constructor? Neither is there a OnFormLoad() method - again you probably meant OnLoad() ?
>
>Putting the data access code in the contstructor *after* the InitializeComponent() call should be OK - but overriding the OnLoad method is the recommended option. The base OnLoad() method is where the form actually raises the Load event so you could use:
protected override void OnLoad(EventArgs e)
>{
>       LoadData()
>       base.OnLoad(e);
>}
You could swap the two statements around - but be aware of the subtle difference since any active Load event handlers will be called by the base.OnLoad(e) line and whether your data will be available at that point will depend on the order of those two statements.....

Thank you for clarifying the INIT and Constructor question.

And thank you for the suggestion to use OnLoad method. The book I am reading has method names OnFormLoad but the author could have simply decided to change the name of the default method (it is possible, right?).

As to your third point to the order of calling LoadData() and base.OnLoad(e), could you please clarify something? If the form is based on the default Win Form why do you need to call base.OnLoad(e)? Is it like DODEFAULT() in VFP?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform