• 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
http://www.codeproject.com/dotnet/PrintingFormReport.asp

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? ..
THANKS


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);
                  mp.EndPrintUnit();
                  extendedHeight += extraHeight;
                  break;
            case ParentControlPrinting.AfterChilds :
                  if (TabControlBoxed)
                        mp.DrawFrame(_Pen, x, y, c.Width, c.Height + extendedHeight);
                  break;
      }
}
0
Jay Toops
Asked:
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) {
                Console.WriteLine(TP.Text);
}

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

0

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