Layout; Adding order Problem

F

Fatih BOY

Hi,

I'm designing an application with plug-in architecture. At start-up, main
form is just an empty System.Windows.Forms.Form component. I'm reading a
plugin folder and getting component to add my main form.

Problem is; i want design my application's layout something like below :

+-----------------------------------+
| Top Menu |
|------------------------------------|
| |
| |
| Tab page |
| |
|____________________ |
| status bar |
+-----------------------------------+

It is ok when i'm adding components with the following attributes and order
:

//
// i.e. : Comes form plugin P
//
topMenu.Dock = System.Windows.Forms.DockStyle.Top;

//
// i.e. : Comes form plugin y
//
statusBar.Dock = System.Windows.Forms.DockStyle.Bottom;

//
// i.e. : Comes form plugin x
//
tabPage.Dock = System.Windows.Forms.DockStyle.Fill;

//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(584, 414);
this.Controls.Add(tabPage);
this.Controls.Add(topMenu);
this.Controls.Add(statusBar);



But since my plugins manager reads plugins directory and then loads plugins
and does not reads my plugins in that order (x, p, y => tabPage, topMenu,
StatusBar) .
I'm not getting the layout that i want to see. Tabpage will fill whole form
instead of filling the region in between statusbar and topmenu if plugin
manager adds them in that order (p, y, x => topMenu, StatusBar, tabPage)

How can i fix this error?!
 
1

100

Hi Faith BOY,
That is right. The frame work starts layouting the components in backwards.
It statrts from the last one on the list. It plavce the last one first then
in the empty space it layouts the second to the last and so forth. You have
to put the fill-docked control at index 0 if you want everything to be ok.

You you might want to do is after loading all plug-ins and add their
controls to the form in the order they appear. you can do something like
this
....
SuspendLayout()
this.Controls.SetChildIndex(tabPage, 0);
ResumeLayout(true);
....
This will move the Page control at index 0 and the controls will be aligned
ok.

HTH
B\rgds
100
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top