|
I have a tabbed form and I'm trying to switch it over to tiled. It looks like this:
TabPage newPage = new TabPage(string.Format("{0}:{1}", cb1.cbInfos[i].usbHandle, cb1.cbInfos[i].boxID));
InitializeControls(controls[i]);
tabCtrlMain.Size = (controls[i].Size);
tabCtrlMain.Width += 20;
tabCtrlMain.Height += 100;
this.Width = tabCtrlMain.Width + 20;
this.Height = tabCtrlMain.Height + 50;
newPage.Controls.Add(controls[i]);
tabCtrlMain.TabPages.Add(newPage);
I saw this example, http://sharpertutorials.com/multiple-document-interface-mdi/[^], but this looks different because they are changing where it refers to Run new Form to Run new Mdi
example:
Application.Run(new Form1());
to
Application.Run(new MDIParent1());
but I'm not seeing where I have that sort of thing to switch over. Does anyone have any ideas how to switch over to tiled from tabbed? I'm fine with the contents of my controls[i] containing the correct information. The tabbed forms look fine. We decided to change the look because we think it will work better with this application. Thanks!
|
|
|
|
|
There's nothing special here. It's really just:
Application.Run(new className);
Instead of calling their startup form the default name of Form1, they changed the name to MDIParent1. Whether of a not a form supports MDI is just a property setting on the form. Just look in the Properties box of your form for "IsMdiContainer".
By the way, everyone is moving AWAY from MDI, not towards it.
After that, I guess you'll have a bunch of code to rewrite as you apparently won't being TabControl anymore. The only person who can tell you what you have to do is yourself since you're the one who designed the app in its current form.
|
|
|
|
|
Cool. That helped. I'm doing this to add it to my existing form and add the existing control that I was previously showing in the tab:
Form newForm = new Form();
InitializeControls(controls[i]);
newForm.Size = (controls[i].Size);
newForm.Width += 20;
newForm.Height += 100;
this.Width = newForm.Width + 20;
this.Height = newForm.Height + 50;
newForm.Controls.Add(controls[i]);
newForm.ShowDialog();
But it's filling up my entire area. Do you know how to scale the control's contents down to 1/4 the size? I think once I do that, it won't be tough to figure out how to position it (tiled) in the right location in my form with the other 4 controls I'm adding. It didn't let me say newForm.size = controls[i].size/4. (operator / can't be applied to system.drawing.size and int)
|
|
|
|
|
Loko at what type the Size property takes, it's an instance of Size. Look at the properties of Size, Height and Width. Sooooo, you just make a new instance of a Size with the new values:
using System.Drawing;
.
.
.
Size newSize = new Size(controls[i].Size.Width / 4, controls[i].Size.Height / 4);
controls[i].Size = newSize;
|
|
|
|