 |
|
 |
Hello YILMAZ,
Thanks a lot for this article it helps me a lot. But i still have problem that when i click on the menu form again a new tab pages added every time. I want that if the form is already acitvated then the forcus should go on that tab pages instead of adding a new tab page every time.
I need help.
feel free to ask any clarity at magicalvictor@gmail.com
thank you very much.
|
|
|
|
 |
|
 |
It help me a lot when my application muts open multi document at the same time
|
|
|
|
 |
|
|
 |
|
 |
Good job man, you developped just enough to let us modify according to our needs.
cheers
|
|
|
|
 |
|
|
 |
|
 |
I had an issue with the MDI children flickering when switching between tabs. For anybody else that runs into this issue here is the solution that worked for me:
add:
using System.Runtime.InteropServices;
and:
private const int WM_SETREDRAW = 11;
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
change this:
private void tabForms_SelectedIndexChanged(object sender,
EventArgs e)
{
if ((tabForms.SelectedTab != null) &&
(tabForms.SelectedTab.Tag != null))
(tabForms.SelectedTab.Tag as Form).Select();
}
to this:
private void tabForms_SelectedIndexChanged(object sender,
EventArgs e)
{
if ((tabForms.SelectedTab != null) &&
(tabForms.SelectedTab.Tag != null))
{
SendMessage(this.Handle, WM_SETREDRAW, false, 0);
(tabForms.SelectedTab.Tag as Form).Select();
SendMessage(this.Handle, WM_SETREDRAW, true, 0);
this.Refresh();
}
}
|
|
|
|
 |
|
 |
Another way to fix this is to change the window state to minimized first:
private void _MDITabControl_SelectedIndexChanged(object sender, EventArgs e)
{
if ((_MDITabControl.SelectedTab != null) && (_MDITabControl.SelectedTab.Tag != null))
{
(_MDITabControl.SelectedTab.Tag as Form).WindowState = FormWindowState.Minimized;
(_MDITabControl.SelectedTab.Tag as Form).Select();
}
}
|
|
|
|
 |
|
 |
Even I came across such flickering problem, this helped me.
Thank you very much.
|
|
|
|
 |
|
 |
Hi Serdar,
I came across your post during work.
I'm currently in the UK but would like to work in Turkey for a Turkish development company hopefully.
C# .NET developer (senior)
10 yrs + experience
C++, C, ASM
Can you give any advice for me?
Thank You.
|
|
|
|
 |
|
|
 |
|
 |
It's a good article, it works very well for me, except one issue.
When I click a tab page to change the child form, there will be showed some normal size child forms and repidly disappair, but when I use CTRL + TAB key to change child form, there's nothing happends something like that.
So is there anyone have better idea?
Thanks and regards.
Jason.
|
|
|
|
 |
|
 |
Excellent and concise article!
I gave it a 5 even though I found one small issue...
I found that if you used the Window menu to select a different mdi child window or if you did so using code anywhere in the app then even though the correct child appeared, the tab stayed where it was.
To fix it I added a little code to the MainWindow_MdiChildActivate method.
Add an else to the "if( this.ActiveMdiChild.Tag == null )" statement:
else
{
TabPage tp = this.ActiveMdiChild.Tag as TabPage;
if( tp != null )
c_MDITabs.SelectedTab = tp;
}
That way anytime an mdi child is activated, the correct tab is selected.
BTW, someone below was having problem getting the windows to be in tabs.
I believe they probably forgot to set the MDIParent property of the windows when they created them, so they are just normal child windows.
|
|
|
|
 |
|
 |
_
How can I hide the (¿menustrip?) that is showed with _ |_|X controls at right when the mdi child forms are minimized and don't exist a main menu strip? good and simple control! thanks!
Fabian Silva
|
|
|
|
 |
|
 |
this code is really useful,
I'm trying to make a program that requires tabbed forms, but the problem is, when i make a change at one instance it changes all the forms.
for example when i change the font at one, the font is change at all the other forms. Any idea how to deal with that?
|
|
|
|
 |
|
 |
I put a PANEL to mainForm for child forms.
And set child form properties
childForm.FormBorderStyle = FormBorderStyle.None;
childForm.ControlBox = false;
childForm.StartPosition = FormStartPosition.Manual;
childForm.WindowState = FormWindowState.Normal;
childForm.Parent = PANEL
And set child form position to centered of panel.
And in the MainForm_SizeChanged events setup child forms positions.
Now, I have no flicker problem.
And I write own tab control like IE.7 with close button on active tabs.
-----------------
Serdar YILMAZ
Senior Developer
|
|
|
|
 |
|
|
 |
|
 |
Serdar,
I'm interesting in the custom tab control with the close button on it.
Is that also available?
Does it somehow get rid of the close button that appears at the end of the menu?
Scott
|
|
|
|
 |
|
 |
Ok.
I'm so busy nowadays. I will send my tabControl your e-mail address.
now, mytabControl like Internet Explorer 7. (same apperance, same close button)
-----------------
Serdar YILMAZ
Senior Developer
|
|
|
|
 |
|
 |
Serdar,
I know all about busy ...
But when you get a chance, just click the email link instead of the reply link to send it to me.
Thanks,
Scott
|
|
|
|
 |
|
 |
Hi Serdar,
Thanks for this code, it was just what I needed for my project and it works great!
I'm really interested in your IE7 tab control update with the close button on the active tab. Can you either post it here or send it to me?
Thanks!
|
|
|
|
 |
|
 |
I have tried so many things and your code seemed like my Jackpot! BUT IT Doesnt work!
Atleast not the way I expected it to- I have a menustrip with
File->Create->1. LC
2. Guarantee
Both these options should open as seperate tabs - not Forms but Tabs-just like IE7.
Now these are the steps I have done(by the way am using c#) :
1. Create main Form
2. Insert the menustrip and the menuItems
3. Insert the Tabcontrol-set the dock to top, Visible setting to False and deleted Both the TabPages. Named it tabForms.
4. Inserted the code in this article to my main Form as appropriate. Both my other forms do not have tab pages but I tried putting them in just to see if that would work. I have the menuItem click code done too.
My forms do open and the functionality works but the tab functionality doesnt show up!!
What am I doing wrong! I'm finding this for 4 days and my manager must be losing his patience now!
Please Help! *****See Code Below:
private void Form1_MdiChildActivate(object sender, EventArgs e)
{
if (this.ActiveMdiChild == null)
tabForms.Visible = false;
// If no any child form, hide tabControl
else
{
this.ActiveMdiChild.WindowState = FormWindowState.Maximized;
// Child form always maximized
// If child form is new and no has tabPage,
// create new tabPage
if (this.ActiveMdiChild.Tag == null)
{
// Add a tabPage to tabControl with child
// form caption
TabPage tp = new TabPage(this.ActiveMdiChild.Text);
tp.Tag = this.ActiveMdiChild;
tp.Parent = tabForms;
tabForms.SelectedTab = tp;
this.ActiveMdiChild.Tag = tp;
this.ActiveMdiChild.FormClosed += new FormClosedEventHandler(ActiveMdiChild_FormClosed);
}
if (!tabForms.Visible) tabForms.Visible = true;
}
}
private void ActiveMdiChild_FormClosed(object sender, FormClosedEventArgs e)
{
((sender as Form).Tag as TabPage).Dispose();
}
private void tabForms_SelectedIndexChanged(object sender, EventArgs e)
{
if ((tabForms.SelectedTab != null) &&
(tabForms.SelectedTab.Tag != null))
(tabForms.SelectedTab.Tag as Form).Select();
}
private void freetextToolStripMenuItem_Click(object sender, EventArgs e)
{
CreateLC newMDIChild = new CreateLC();
// Set the Parent Form of the Child window.
newMDIChild.MdiParent = this;
// Display the new form.
newMDIChild.Show();
}
public void SetMDIList()
{
Form activeChild = this.ActiveMdiChild;
// Create the MenuItem to be used to display an MDI list.
MenuItem freetextToolStripMenuItem = new MenuItem();
MenuItem createToolStripMenuItem = new MenuItem();
// Set this menu item to be used as an MDI list
createToolStripMenuItem.MdiList = true;
freetextToolStripMenuItem.MdiList = true;
}
private void guaranteeToolStripMenuItem1_Click(object sender, EventArgs e)
{
CreateGuarantee newMDIChild = new CreateGuarantee();
// Set the Parent Form of the Child window.
newMDIChild.MdiParent = this;
// Display the new form
newMDIChild.Show();
}
|
|
|
|
 |
|
 |
I don't know what is the problem.
Review "tabForms_SelectedIndexChanged" procedure.
Or send me sample code.
-----------------
Serdar YILMAZ
Senior Developer
|
|
|
|
 |
|
 |
Thanks
|
|
|
|
 |
|
 |
When you set the the Height-property of the tab control to 20, it is perfect for using!
|
|
|
|
 |
|
 |
Bence Ana Formun WM_MDICHILDCREATE mesajında oluştursan tabları daha iyi olur.
|
|
|
|
 |