CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  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.

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