显示嵌套tabcontrol所需的帮助 [英] Display help needed with nested tabcontrols
问题描述
我;我试图以编程方式编写tabcontrol中的tabcontrol。
这是它应该是什么样子:
外部tabcontrol:
[仪表板] [同步作业1]
然后在同步作业1标签下我正试图显示这个标签页:
[目的地]
所以,我有一个外tabcontrol然后是一个内部tabcontrol。一旦我理解了这两个控件如何嵌套并且我可以显示它们,我将在内部tabcontrol中添加一些tabPages。
我的代码如下,当我点击同步作业1标签页不显示内部tabcontrol上的目标标签页。
感谢您的帮助...
I;m trying to programatically code a tabcontrol within a tabcontrol.
Here is what it is supposed to look like:
Outer tabcontrol:
[Dashboard] [Sync Job 1]
Then under the Sync Job 1 tabPage I'm trying to show this tabPage:
[Destination]
So, I have an outer tabcontrol and then an inner tabcontrol. Once I understand how these two controls nest and I can display them, I will add a few more tabPages to the inner tabcontrol.
My code below, when I click on the Sync Job 1 tabPage does not show the Destination tabPage on the inner tabcontrol.
Thanks for any help...
TabPage dashboardTabPage = new TabPage("Dashboard Summary");
TabControl maintc = new TabControl();
int tcLeft = groupBoxDashboardSummary.Left + 4;
int tcTop = groupBoxDashboardSummary.Top + 20;
int tcHeight = groupBoxDashboardSummary.Height - 25;
int tcWidth = groupBoxDashboardSummary.Width - 6;
maintc.Location = new Point(tcLeft, tcTop);
maintc.Height = tcHeight;
maintc.Width = tcWidth;
maintc.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right);
maintc.TabPages.Add(dashboardTabPage);
this.Controls.AddRange(new Control[] { maintc });
TabPage syncJobTabPage = new TabPage(syncJobTitle);
maintc.TabPages.Add(syncJobTabPage);
TabPage destinationTabPage = new TabPage("Destination");
TabControl tcSync = new TabControl();
int tcSyncLeft = groupBoxDashboardSummary.Left + 14;
int tcSyncTop = groupBoxDashboardSummary.Top + 40;
int tcSyncHeight = groupBoxDashboardSummary.Height - 45;
int tcSyncWidth = groupBoxDashboardSummary.Width - 16;
tcSync.Location = new Point(tcSyncLeft, tcSyncTop);
tcSync.Height = tcSyncHeight;
tcSync.Width = tcSyncWidth;
tcSync.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right);
tcSync.TabPages.Add(destinationTabPage);
this.Controls.AddRange(new Control[] { tcSync });
maintc.BringToFront();
推荐答案
您好rfresh,
我找到了解决方案对于您的查询,请尝试下面的代码,它适用于我。
Hi rfresh,
I found solution for your query, try the below code it's working for me.
TabPage dashboardTabPage = new TabPage("Dashboard Summary");
TabControl maintc = new TabControl();
// maintc.Width = this.Width;
// maintc.Height = this.Height;
// int tcLeft = groupBoxDashboardSummary.Left + 4;
// int tcTop = groupBoxDashboardSummary.Top + 20;
// int tcHeight = groupBoxDashboardSummary.Height - 25;
// int tcWidth = groupBoxDashboardSummary.Width - 6;
// maintc.Location = new Point(tcLeft, tcTop);
// maintc.Height = tcHeight;
// maintc.Width = tcWidth;
maintc.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right);
maintc.TabPages.Add(dashboardTabPage);
this.Controls.AddRange(new Control[] { maintc });
TabPage syncJobTabPage = new TabPage("syncJobTitle");
maintc.TabPages.Add(syncJobTabPage);
TabPage destinationTabPage = new TabPage("Destination");
TabControl tcSync = new TabControl();
// int tcSyncLeft = groupBoxDashboardSummary.Left + 14;
//int tcSyncTop = groupBoxDashboardSummary.Top + 40;
//int tcSyncHeight = groupBoxDashboardSummary.Height - 45;
// int tcSyncWidth = groupBoxDashboardSummary.Width - 16;
// tcSync.Location = new Point(tcSyncLeft, tcSyncTop);
// tcSync.Height = tcSyncHeight;
//tcSync.Width = tcSyncWidth;
tcSync.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right);
tcSync.TabPages.Add(destinationTabPage);
this.Controls.AddRange(new Control[] { tcSync });
//maintc.BringToFront();
syncJobTabPage.Controls.Add(tcSync); // Add this line to your coding.
i希望这会对你有所帮助。
感谢
Mohan G
i hope this will help you.
Thank's
Mohan G
这篇关于显示嵌套tabcontrol所需的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!