i putting wizard has multiple pages user shown. need 1 page able access data user choice on previous page. idea pass in parameter reference constructors of both pages, , assign property parameter, change isn't persisting between pages. i'm assuming means incorrectly using ref. cannot pass data directly methods controlled wizard host.
host initialization:
wizardhost host = new wizardhost(); using (host) { host.text = migration.properties.resources.appname; host.showfirstbutton = false; host.showlastbutton = false; host.wizardcompleted += new wizardhost.wizardcompletedeventhandler(this.host_wizardcompleted); reference<dbmanip> dbcontrollerref = new reference<dbmanip>(); bool exportpathactive = false; host.wizardpages.add(1, new page1()); host.wizardpages.add(2, new page2(dbcontrollerref)); host.wizardpages.add(3, new page3(dbcontrollerref, ref exportpathactive)); host.wizardpages.add(4, new page4(dbcontrollerref, ref exportpathactive)); host.wizardpages.add(5, new page5()); host.loadwizard(); host.showdialog();
page ref linked property:
public page3(reference<dbmanip> dbcontrollerref, ref bool exportpathactive) { this.initializecomponent(); this.dbcontrollerref = dbcontrollerref; this.page3body.text = migration.properties.resources.page3body; this.exportpathactiveref = exportpathactive; } public reference<dbmanip> dbcontrollerref { get; private set; }
if modify exportpathactive in constructor modification preserved in next page, property assigned passed parameter doesn't preserve reference. i'm pretty new c#, silly i'm missing, can't find on google or looking around so.
i have decided on making class called persistentdata property called exportpathactive, , passing that. works , can expand hold more data if needed. i'll wait approve in case more elegant approach posted.
the class:
/// <summary> /// store pass data between pages. /// </summary> public class persistentdata { /// <summary> /// initializes new instance of <see cref="persistentdata"/> class. /// </summary> public persistentdata() { this.exportpathactive = false; } /// <summary> /// gets or sets value indicating whether [export path active]. /// </summary> /// <value> /// <c>true</c> if [export path active]; otherwise, <c>false</c>. /// </value> public bool exportpathactive { get; set; } }
Comments
Post a Comment