CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2008
    Posts
    21

    Concept of pages system using by UserControl

    I tried to make application where is one form with Panel control where id displaying user control (page). This page can have button when can call other page which is display to parent panel control. Main from have some BarButton control for quick choose.
    Problem is with button on pages. When I moving among pages, is makes multiple calling same pages (it is increase). Why I tried to call helped by events and delegates to main frame but without any improve.
    Cut of main form:
    Code:
    public void SwitchPage(pageType pg, string capt)
    {            
                gc.Controls.Clear();                        
                pg.parent = this;
                gc.Controls.Add(pg);            
    
                pg.Left = 20;
                pg.Top = 20;
                pg.Dock = DockStyle.Fill;
                pg.Show();
    }
    
     private void MainWind_Load(object sender, EventArgs e)
    {
                pgLogin pg = new pgLogin();
                SwitchPage(pg, null);
    }
    PageType is main PageControl (for future common parts)
    Code:
    public partial class pageType : DevExpress.XtraEditors.XtraUserControl
    {
     
           public bool DiableTextInput = false;
           public MainWind parent;        
           public pageType()
           {
                InitializeComponent();            
           }
        
    }
    Page Login one of derived from pageType
    Code:
    public partial class pgLogin : TW_HMI.page.pageType
    {
            public pgLogin()
            {
                InitializeComponent();
            }
    
            private void labelControl2_DoubleClick(object sender, EventArgs e)
            {
                pgMain pg = new pgMain();
                parent.SwitchPage(pg, null);
            }
    }
    Page Login one of derived from pageMain
    Code:
    public partial class pgMain : TW_HMI.page.pageType
    {
            public pgLogin()
            {
                InitializeComponent();
            }
    
            private void labelControl1_DoubleClick(object sender, EventArgs e)
            {
                pgOp1 pg = new pgMain();
                parent.SwitchPage(pg, null);
            }
    
            private void labelControl2_DoubleClick(object sender, EventArgs e)
            {
                pgLogin pg = new pgLogin();
                 parent.SwitchPage(pg, null);
            }
    
    }
    I was any better concept ?
    Thank for any ideas.
    Last edited by pawl; March 29th, 2012 at 04:51 AM.

  2. #2
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Concept of pages system using by UserControl

    Sorry I didn't get your idea. Maybe zip what you already have and post the zupped code Maybe when I test your code I'll get the idea behind that code.
    Is the maonForm an MDI window? what isthe forms loaded in the FormLoad event is this a child window?
    And BTW please use code Tags
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  3. #3
    Join Date
    Apr 2008
    Posts
    21

    Re: Concept of pages system using by UserControl

    I rewrite to standarrd C# tools (because in original concept I use DevExpress components)
    But idea is same.

    I isn't MDI mybe, like SDI (only one windows visible).

    I attached codde all apication.
    Attached Files Attached Files

  4. #4
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Concept of pages system using by UserControl

    Quote Originally Posted by pawl View Post
    I rewrite to standarrd C# tools (because in original concept I use DevExpress components)
    But idea is same.

    I isn't MDI mybe, like SDI (only one windows visible).

    I attached codde all apication.
    Thx !

    I looked to your program and saw yor problem
    Code:
    ]
     
     
    privatevoid typepage_Load(object sender, EventArgs e)
    {
    if (parent != null)
    {
    parent.buttonselect += newAction<int>(buttsel);
    MenuGenerate();
    }
    }
    You are addiong a new delegate everytime when you are loading that form "" You never remopve them. So this delegate is done more and more and more as longer the program is used and the panels are changed

    I have added the cirrected file now when a button is clicked the buttonsel only fires one time
    Attached Files Attached Files
    Last edited by JonnyPoet; March 29th, 2012 at 05:13 PM.
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured