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.
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
1 Attachment(s)
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.
1 Attachment(s)
Re: Concept of pages system using by UserControl
Quote:
Originally Posted by
pawl
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 :wave: