Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WinForms App Refresh Problem?
Message
From
28/04/2010 10:39:39
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01462299
Message ID:
01462349
Views:
44
Just guessing, but try this: load the panel after you've added it to the controls collection (probably put the event hookups there too):
private void _LoadPanel(Panels PanelToLoad)
{
    // Your switch case stuff here

    Text = ActivePanel.ToString();

    ActivePanel.Left = VerticleSplitter.Left + VerticleSplitter.Width;
    ActivePanel.Top = tbrStandard.Top + tbrStandard.Height;
    ActivePanel.PanelType = PanelToLoad;

    // move this above the LoadPanel
    Controls.Add(ActivePanel);

    ActivePanel.LoadPanel();

    ActivePanel.ActionOccured += new ActionOccuredEventHandler(ActivePanel_ActionOccured);
    ActivePanel.DataChanged += new DataChangedEventHandler(ActivePanel_DataChanged);
    ActivePanel.ButtonClicked += new ProjectButtonClickedEventHandler(ActivePanel_ButtonClicked);

    _Resize();
}
I have no idea if this will make it work, but it's worth a try.

~~Bonnie




>I am developing a WinForms app for a client. The app walks the user through a series of views, sort of like a wizard.
>Here are 3 views with the client info removed and my comments in red
>
>Here's the first view. The user can select which project they want.
>
>In this view I have selected the project Burger King. All the data is appearing fine.
>
>In the third view I have selected another project. Notice that the data in the text fields in not being refreshed.
>
>Each "view" is a panel that is being loaded at the time the user clicked Next. The preview panel is remove and the new panel is
>added. Here's the AddPanel method code:
>
>
>private void _LoadPanel(Panels PanelToLoad)
>{
>    if(ActivePanel != null)
>    {
>        ActivePanel.Visible = false;
>        ActivePanel.UnLoadPanel();
>        Controls.Remove(ActivePanel);
>        ActivePanel = null;
>    }
>
>    switch (PanelToLoad)
>    {
>        case Panels.Welcome:
>            ActivePanel = new pnlWelcome();
>            break;
>
>        case Panels.ProjectInfo:
>            ActivePanel = new pnlProjectInfo();
>            break;
>    
>        case Panels.Query:
>            ActivePanel = new pnlQuery();
>            break;
>
>        case Panels.QueryResults:
>            ActivePanel = new pnlQueryResults();
>            break;
>
>        case Panels.BOMSelections:
>            ActivePanel = new pnlBOMSelections();
>            break;
>
>        case Panels.Tribal:
>            ActivePanel = new pnlTribals();
>            break;
>
>        case Panels.Prices:
>            ActivePanel = new pnlPrices();
>            break;
>
>        case Panels.Ratios:
>            ActivePanel = new pnlRatios();
>            break;
>    }
>
>    Text = ActivePanel.ToString();
>
>    ActivePanel.Left = VerticleSplitter.Left + VerticleSplitter.Width;
>    ActivePanel.Top = tbrStandard.Top + tbrStandard.Height;
>    ActivePanel.PanelType = PanelToLoad;
>
>    ActivePanel.LoadPanel();
>
>    ActivePanel.ActionOccured += new ActionOccuredEventHandler(ActivePanel_ActionOccured);
>    ActivePanel.DataChanged += new DataChangedEventHandler(ActivePanel_DataChanged);
>    ActivePanel.ButtonClicked += new ProjectButtonClickedEventHandler(ActivePanel_ButtonClicked);
>
>    Controls.Add(ActivePanel);
>
>    _Resize();
>}
>
>In the Project Info panel's LoadPanel method I have:
>
>
>public override void LoadPanel()
>{
>    if (csCOSApp.ActiveProject.ProjectId == 0)
>    {
>        lblPageCaption.Text = "Project Information - New Project";
>        ItemMode = ProjectItemMode.New;
>    }
>    else
>    {
>        lblPageCaption.Text = "Project Information - " + csCOSApp.ActiveProject.ProjectNum;
>        ItemMode = ProjectItemMode.View;
>    }
>
>    _LoadWarehouseLists();
>
>    txtCustomerName.Text = csCOSApp.ActiveProject.CustomerName; // Data is correct here
>    txtCustomerCode.Text = csCOSApp.ActiveProject.CustomerCode; // Data is correct here
>    lblProjectNum.Text = csCOSApp.ActiveProject.ProjectNum;
>    lblProjectDate.Text = csCOSApp.ActiveProject.ProjectDT.ToString();
>    txtComments.Text = csCOSApp.ActiveProject.Comments;
>    lblProjectDate.Visible = (csCOSApp.ActiveProject.ProjectId > -1);
>    lblProjectNum.Visible = (csCOSApp.ActiveProject.ProjectId > -1);
>
>    _SetNextButton();
>}
>
>
>Notice where my comments are. When I step this through, the value in the csCOSApp.ActiveProject.CustomerName property is
>correct, as is the value of txtCustomerName.Text.
>
>Yet when I run it without stopping the text values are not refreshing.
>
>Anyone see what's going on? Is there some wat to force a refresh?
>
>Thanks
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform