• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 580
  • Last Modified:

How can I alter this to loop through all tab controls...

I am using some code "formprinting.cs" from

I am trying to print all the tabs in a tab control using this...
however the code does not support it..
it  will only print the selected tab... what i'd like to be able to do is
print all the tabs one after the other vertically.
Anyone have a clue on how i could achieve this? ..

this adds it
AddDelegateToPrintControl("System.Windows.Forms.TabControl", new ControlPrinting(PrintTabControl));

this is the function
public void PrintTabControl(System.Windows.Forms.Control c,
      ParentControlPrinting typePrint,
      MultiPageManagement mp,
      Single x, Single y,
      ref Single extendedHeight, out bool ScanForChildControls)
      ScanForChildControls = true;
      System.Windows.Forms.TabControl tc = (TabControl) c;
      _Pen = new Pen(Color.Gray);
      switch (typePrint)
            case ParentControlPrinting.BeforeChilds :
                  //Nom du TabPage
                  Single extraHeight = mp.BeginPrintUnit(y, tc.ItemSize.Height);   //Space required for tab page caption
                  System.Windows.Forms.TabPage tp = tc.SelectedTab;
                  Font printFont = new Font(tp.Font.Name, tp.Font.Size, FontStyle.Bold);
                  Single h = mp.FontHeight(printFont);
                  if (h > tc.ItemSize.Height)
                        h = tc.ItemSize.Height;
                  mp.DrawString(tp.Text, printFont, Brushes.Black, x, y + (tc.ItemSize.Height - h) / 2, tp.Width, h);
                  mp.DrawLines(_Pen, x, y + tc.ItemSize.Height, x + tc.Width, y + tc.ItemSize.Height);
                  extendedHeight += extraHeight;
            case ParentControlPrinting.AfterChilds :
                  if (TabControlBoxed)
                        mp.DrawFrame(_Pen, x, y, c.Width, c.Height + extendedHeight);
Jay Toops
Jay Toops
  • 2
1 Solution
Diego PazosCommented:
I didn't really get what you were trying to do with that code. There is too much missing code to get it.
If what you want is to iterate through the pages in a tabControl, this does it:

foreach (TabPage TP in tabControl1.TabPages) {

Change the 'Console.WriteLine' statement to whatever you want to do with the pages.
Jay ToopsAuthor Commented:
hmm possibly ..... I'll try that ..
Jay ToopsAuthor Commented:
try that link for FULL source code or i can post it here
but its quite large


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now