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

Posted on 2005-05-12
Last Modified: 2012-08-14
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);
Question by:Jay Toops
    LVL 3

    Accepted Solution

    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.
    LVL 10

    Author Comment

    by:Jay Toops
    hmm possibly ..... I'll try that ..
    LVL 10

    Author Comment

    by:Jay Toops
    try that link for FULL source code or i can post it here
    but its quite large


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now