Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. print concept very urgent help me

print concept very urgent help me

Scheduled Pinned Locked Moved C#
csharpgraphicshelp
4 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cse vidhya
    wrote on last edited by
    #1

    hi, i am print concept to print the dtagrid rows..... i am using c# coding...... while taking the print i am getting output as(givn below).... Pepsi 500ml £1.09 coke 500ml £1.09 Fanta 500ml £1.09 Sprite 500ml .99p but my uotput should be like the given below...... Pepsi 500ml £1.09 coke 500ml £1.09 Fanta 500ml £1.09 Sprite 500ml .99p tell me where i have to change my coding paart: my coding is; public class DataGridPrinter { private PrintDocument ThePrintDocument; private DataTable TheTable; private DataGridView TheDataGrid; public int RowCount = 0; // current count of rows; //private const int kVerticalCellLeeway = 10; public int PageNumber = 1; public ArrayList Lines = new ArrayList(); int PageWidth; int PageHeight; int TopMargin; int BottomMargin; public DataGridPrinter(DataGridView aGrid, PrintDocument aPrintDocument, DataTable aTable) { // // TODO: Add constructor logic here // TheDataGrid = aGrid; ThePrintDocument = aPrintDocument; TheTable = aTable; // TheTable.Columns.RemoveAt(3); PageWidth = 350; TopMargin = 30; // PageWidth = ThePrintDocument.DefaultPageSettings.PaperSize.Width; PageHeight = ThePrintDocument.DefaultPageSettings.PaperSize.Height; //TopMargin = ThePrintDocument.DefaultPageSettings.Margins.Top; //TopMargin = 100; BottomMargin = ThePrintDocument.DefaultPageSettings.Margins.Bottom; } public void DrawHeader(Graphics g, int ff) { //SolidBrush ForeBrush = new SolidBrush(TheDataGrid.HeaderForeColor); //SolidBrush BackBrush = new SolidBrush(TheDataGrid.HeaderBackColor); //Pen TheLinePen = new Pen(TheDataGrid.GridLineColor, 1); StringFormat cellformat = new StringFormat(); cellformat.Trimming = StringTrimming.EllipsisCharacter; cellformat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit | StringFormatFlags.NoClip; int ht = ff + 2; int columnwidth = 30; int initialRowCount = RowCount; // draw the table header //float startxposition = TheDataGrid.Location.X; float startxposition = 30; RectangleF nextcellbounds = new RectangleF(0, 0, 0, 0); RectangleF HeaderBounds = new RectangleF(0, 0, 0, 0); HeaderBounds.X = TheDataGrid.Location.X; HeaderBounds.Y = TheDataGrid.Location.Y + TopMargin + (RowCount - initialRowCount) * (TheDataGrid.Font.SizeInPoints + ht); HeaderBounds.Height = TheDataGrid.Font.SizeInPoints + ht; HeaderBounds.Width = PageWidth; //g.FillRectangle(BackBrush, HeaderBounds); for (int k = 0; k < TheTable.Columns.

    C 1 Reply Last reply
    0
    • C cse vidhya

      hi, i am print concept to print the dtagrid rows..... i am using c# coding...... while taking the print i am getting output as(givn below).... Pepsi 500ml £1.09 coke 500ml £1.09 Fanta 500ml £1.09 Sprite 500ml .99p but my uotput should be like the given below...... Pepsi 500ml £1.09 coke 500ml £1.09 Fanta 500ml £1.09 Sprite 500ml .99p tell me where i have to change my coding paart: my coding is; public class DataGridPrinter { private PrintDocument ThePrintDocument; private DataTable TheTable; private DataGridView TheDataGrid; public int RowCount = 0; // current count of rows; //private const int kVerticalCellLeeway = 10; public int PageNumber = 1; public ArrayList Lines = new ArrayList(); int PageWidth; int PageHeight; int TopMargin; int BottomMargin; public DataGridPrinter(DataGridView aGrid, PrintDocument aPrintDocument, DataTable aTable) { // // TODO: Add constructor logic here // TheDataGrid = aGrid; ThePrintDocument = aPrintDocument; TheTable = aTable; // TheTable.Columns.RemoveAt(3); PageWidth = 350; TopMargin = 30; // PageWidth = ThePrintDocument.DefaultPageSettings.PaperSize.Width; PageHeight = ThePrintDocument.DefaultPageSettings.PaperSize.Height; //TopMargin = ThePrintDocument.DefaultPageSettings.Margins.Top; //TopMargin = 100; BottomMargin = ThePrintDocument.DefaultPageSettings.Margins.Bottom; } public void DrawHeader(Graphics g, int ff) { //SolidBrush ForeBrush = new SolidBrush(TheDataGrid.HeaderForeColor); //SolidBrush BackBrush = new SolidBrush(TheDataGrid.HeaderBackColor); //Pen TheLinePen = new Pen(TheDataGrid.GridLineColor, 1); StringFormat cellformat = new StringFormat(); cellformat.Trimming = StringTrimming.EllipsisCharacter; cellformat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit | StringFormatFlags.NoClip; int ht = ff + 2; int columnwidth = 30; int initialRowCount = RowCount; // draw the table header //float startxposition = TheDataGrid.Location.X; float startxposition = 30; RectangleF nextcellbounds = new RectangleF(0, 0, 0, 0); RectangleF HeaderBounds = new RectangleF(0, 0, 0, 0); HeaderBounds.X = TheDataGrid.Location.X; HeaderBounds.Y = TheDataGrid.Location.Y + TopMargin + (RowCount - initialRowCount) * (TheDataGrid.Font.SizeInPoints + ht); HeaderBounds.Height = TheDataGrid.Font.SizeInPoints + ht; HeaderBounds.Width = PageWidth; //g.FillRectangle(BackBrush, HeaderBounds); for (int k = 0; k < TheTable.Columns.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Wow. I assume your datagrid does not display this way on the form, right ?

      cse.vidhya wrote:

      for (int i = initialRowCount; i < TheTable.Rows.Count; i++) { DataRow dr = TheTable.Rows[i]; int startxposition = TheDataGrid.Location.X;

      What do you think this will do ? I'm suspecting it will create a new row to be printed for every row in your data set. So, it sounds like you want to change i++ to i+=2, read two rows every time, and draw them next to each other.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      C 1 Reply Last reply
      0
      • C Christian Graus

        Wow. I assume your datagrid does not display this way on the form, right ?

        cse.vidhya wrote:

        for (int i = initialRowCount; i < TheTable.Rows.Count; i++) { DataRow dr = TheTable.Rows[i]; int startxposition = TheDataGrid.Location.X;

        What do you think this will do ? I'm suspecting it will create a new row to be printed for every row in your data set. So, it sounds like you want to change i++ to i+=2, read two rows every time, and draw them next to each other.

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        C Offline
        C Offline
        cse vidhya
        wrote on last edited by
        #3

        i gave i++ to 1+=2 but i am getting only 1st row and 3rd row .. and the 2nd row and 4th rows are not coming.. i need all the rows while printing like below Printed out should be like Pepsi 500ml £1.09 coke 500ml £1.09 Fanta 500ml £1.09 Sprite 500ml .99p

        C 1 Reply Last reply
        0
        • C cse vidhya

          i gave i++ to 1+=2 but i am getting only 1st row and 3rd row .. and the 2nd row and 4th rows are not coming.. i need all the rows while printing like below Printed out should be like Pepsi 500ml £1.09 coke 500ml £1.09 Fanta 500ml £1.09 Sprite 500ml .99p

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Like I said, you plain do not understand your own code. As I said, going to i+=2 means that you're not starting a new row for every item. Now you need to add code to draw every second item on the same row, or you will plainly get every second item only printed.

          Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups