Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
4.33/5 (2 votes)
See more:
I wrote this code and I have a problem because I need a place fifth record in new page but when the list is end my print preview dont show more of 1 page.
Please guys help me How I can fix that

C#
    // Create string to draw.
    String drawString = "Организация: Петко Ангелов БГ ЕООД";
    String drawBulstat = "Булстат: 160074586";
    String drawRKO = "Разходен касов ордер        No: ";
    String drawStart_date = "" + start_date.Text;

    String drawTo = "Да се плати на: " + driver_1.Text;
    String drawTo_2 = "Да се плати на: " + driver_2.Text;

    String drawOsnovanie = "Аванс за композиция: влекач " + truck_number.Text + " ремарке " + trailer_number.Text + "и дестинация " + destination.Text;
    String drawStringSum = "Сума:" + (Convert.ToInt32(advance_sum.Text) / 2).ToString() + " " + curency.Text;

    String drawUser = "Дал сума: " + username_txt.Text;
    String drawDriver_1 = driver_1.Text;
    String drawDriver_2 = driver_2.Text;

    // Create font and brush.
    Font drawFont = new Font("Times New Roman", 14);
    SolidBrush drawBrush = new SolidBrush(Color.Black);

    // Create rectangle for drawing.
    float x = 80.0F;
    float y_1 = 110.0F;
    float y = 50.0F;
    // Координати за вторият ордер
    float y_2 = 295.0F;
    // Координати за третият ордер
    float y_3 = 540.0F;
    // Координати за четвъртият ордер
    float y_4 = 785.0F;
    // Координати за пети ордер
    float y_5 = 1030.0F;
    float width = 400.0F;
    float height = 30.0F;



    RectangleF drawRect = new RectangleF(x, y, width, height);
    RectangleF drawRect_1 = new RectangleF(x + 400, y, width, height);
    RectangleF drawRect_2 = new RectangleF(x, y + 30, width, height + 30);
    RectangleF drawRect_3 = new RectangleF(x + 400, y + 30, width, height + 30);
    RectangleF drawRect_4 = new RectangleF(x, y_1, width + 300, height);
    RectangleF drawRect_5 = new RectangleF(x, y_1 + 30, width + 300, height + 15);
    RectangleF drawRect_6 = new RectangleF(x, y_1 + 75, width + 300, height);
    RectangleF drawRect_7 = new RectangleF(x, y_1 + 105, width, height + 15);
    RectangleF drawRect_8 = new RectangleF(x + 400, y_1 + 105, width - 100, height + 15);

    //Втори ордер при двама шофьори

    RectangleF drawRect_9 = new RectangleF(x, y_2, width, height);
    RectangleF drawRect_10 = new RectangleF(x + 400, y_2, width - 100, height);
    RectangleF drawRect_11 = new RectangleF(x, y_2 + 30, width, height);
    RectangleF drawRect_12 = new RectangleF(x + 400, y_2 + 30, width - 100, height);
    RectangleF drawRect_13 = new RectangleF(x, y_2 + 60, width + 300, height);
    RectangleF drawRect_14 = new RectangleF(x, y_2 + 90, width + 300, height + 15);
    RectangleF drawRect_15 = new RectangleF(x, y_2 + 135, width + 300, height);
    RectangleF drawRect_16 = new RectangleF(x, y_2 + 165, width, height + 15);
    RectangleF drawRect_17 = new RectangleF(x + 400, y_2 + 165, width - 100, height + 15);

    //Трети ордер при двама шофьори

    RectangleF drawRect_18 = new RectangleF(x, y_3, width, height);
    RectangleF drawRect_19 = new RectangleF(x + 400, y_3, width - 100, height);
    RectangleF drawRect_20 = new RectangleF(x, y_3 + 30, width, height);
    RectangleF drawRect_21 = new RectangleF(x + 400, y_3 + 30, width - 100, height);
    RectangleF drawRect_22 = new RectangleF(x, y_3 + 60, width + 300, height);
    RectangleF drawRect_23 = new RectangleF(x, y_3 + 90, width + 300, height + 15);
    RectangleF drawRect_24 = new RectangleF(x, y_3 + 135, width + 300, height);
    RectangleF drawRect_25 = new RectangleF(x, y_3 + 165, width, height + 15);
    RectangleF drawRect_26 = new RectangleF(x + 400, y_3 + 165, width - 100, height + 15);

    //Четвърти ордер при двама шофьори

    RectangleF drawRect_27 = new RectangleF(x, y_4, width, height);
    RectangleF drawRect_28 = new RectangleF(x + 400, y_4, width - 100, height);
    RectangleF drawRect_29 = new RectangleF(x, y_4 + 30, width, height);
    RectangleF drawRect_30 = new RectangleF(x + 400, y_4 + 30, width - 100, height);
    RectangleF drawRect_31 = new RectangleF(x, y_4 + 60, width + 300, height);
    RectangleF drawRect_32 = new RectangleF(x, y_4 + 90, width + 300, height + 15);
    RectangleF drawRect_33 = new RectangleF(x, y_4 + 135, width + 300, height);
    RectangleF drawRect_34 = new RectangleF(x, y_4 + 165, width, height + 15);
    RectangleF drawRect_35 = new RectangleF(x + 400, y_4 + 165, width - 100, height + 15);

    //Пети ордер при двама шофьори

    RectangleF drawRect_36 = new RectangleF(x, y_5, width, height);
    RectangleF drawRect_37 = new RectangleF(x + 400, y_5, width - 100, height);
    RectangleF drawRect_38 = new RectangleF(x, y_5 + 30, width, height);
    RectangleF drawRect_39 = new RectangleF(x + 400, y_5 + 30, width - 100, height);
    RectangleF drawRect_40 = new RectangleF(x, y_5 + 60, width + 300, height);
    RectangleF drawRect_41 = new RectangleF(x, y_5 + 90, width + 300, height + 15);
    RectangleF drawRect_42 = new RectangleF(x, y_5 + 135, width + 300, height);
    RectangleF drawRect_43 = new RectangleF(x, y_5 + 165, width, height + 15);
    RectangleF drawRect_44 = new RectangleF(x + 400, y_5 + 165, width - 100, height + 15);





    // Draw rectangle to screen.
    Pen blackPen = new Pen(Color.Black);
    e.Graphics.DrawRectangle(blackPen, x, y, width, height);
    e.Graphics.DrawRectangle(blackPen, x + 400, y, width - 100, height);
    e.Graphics.DrawRectangle(blackPen, x, y, width, height + 30);
    e.Graphics.DrawRectangle(blackPen, x + 400, y, width - 100, height + 30);
    e.Graphics.DrawRectangle(blackPen, x, y_1, width + 300, height);
    e.Graphics.DrawRectangle(blackPen, x, y_1 + 30, width + 300, height + 15);
    e.Graphics.DrawRectangle(blackPen, x, y_1 + 75, width + 300, height);
    e.Graphics.DrawRectangle(blackPen, x, y_1 + 105, width, height + 15);
    e.Graphics.DrawRectangle(blackPen, x + 400, y_1 + 105, width - 100, height + 15);



    //Втори ордер

    e.Graphics.DrawRectangle(blackPen, x, y_2, width, height);
    e.Graphics.DrawRectangle(blackPen, x + 400, y_2, width - 100, height);
    e.Graphics.DrawRectangle(blackPen, x, y_2 + 30, width, height);
    e.Graphics.DrawRectangle(blackPen, x + 400, y_2 + 30, width - 100, height);
    e.Graphics.DrawRectangle(blackPen, x, y_2 + 60, width + 300, height);
    e.Graphics.DrawRectangle(blackPen, x, y_2 + 90, width + 300, height + 15);
    e.Graphics.DrawRectangle(blackPen, x, y_2 + 135, width + 300, height);
    e.Graphics.DrawRectangle(blackPen, x, y_2 + 165, width, height + 15);
    e.Graphics.DrawRectangle(blackPen, x + 400, y_2 + 165, width - 100, height + 15);

    //Трети ордер

    e.Graphics.DrawRectangle(blackPen, x, y_3, width, height);
    e.Graphics.DrawRectangle(blackPen, x + 400, y_3, width - 100, height);
    e.Graphics.DrawRectangle(blackPen, x, y_3 + 30, width, height);
    e.Graphics.DrawRectangle(blackPen, x + 400, y_3 + 30, width - 100, height);
    e.Graphics.DrawRectangle(blackPen, x, y_3 + 60, width + 300, height);
    e.Graphics.DrawRectangle(blackPen, x, y_3 + 90, width + 300, height + 15);
    e.Graphics.DrawRectangle(blackPen, x, y_3 + 135, width + 300, height);
    e.Graphics.DrawRectangle(blackPen, x, y_3 + 165, width, height + 15);
    e.Graphics.DrawRectangle(blackPen, x + 400, y_3 + 165, width - 100, height + 15);

    //Четвърти ордер

    e.Graphics.DrawRectangle(blackPen, x, y_4, width, height);
    e.Graphics.DrawRectangle(blackPen, x + 400, y_4, width - 100, height);
    e.Graphics.DrawRectangle(blackPen, x, y_4 + 30, width, height);
    e.Graphics.DrawRectangle(blackPen, x + 400, y_4 + 30, width - 100, height);
    e.Graphics.DrawRectangle(blackPen, x, y_4 + 60, width + 300, height);
    e.Graphics.DrawRectangle(blackPen, x, y_4 + 90, width + 300, height + 15);
    e.Graphics.DrawRectangle(blackPen, x, y_4 + 135, width + 300, height);
    e.Graphics.DrawRectangle(blackPen, x, y_4 + 165, width, height + 15);
    e.Graphics.DrawRectangle(blackPen, x + 400, y_4 + 165, width - 100, height + 15);

    //Пети ордер

    e.Graphics.DrawRectangle(blackPen, x, y_5, width, height);
    e.Graphics.DrawRectangle(blackPen, x + 400, y_5, width - 100, height);
    e.Graphics.DrawRectangle(blackPen, x, y_5 + 30, width, height);
    e.Graphics.DrawRectangle(blackPen, x + 400, y_5 + 30, width - 100, height);
    e.Graphics.DrawRectangle(blackPen, x, y_5 + 60, width + 300, height);
    e.Graphics.DrawRectangle(blackPen, x, y_5 + 90, width + 300, height + 15);
    e.Graphics.DrawRectangle(blackPen, x, y_5 + 135, width + 300, height);
    e.Graphics.DrawRectangle(blackPen, x, y_5 + 165, width, height + 15);
    e.Graphics.DrawRectangle(blackPen, x + 400, y_5 + 165, width - 100, height + 15);


    // Set format of string.
    StringFormat drawFormat = new StringFormat();
    drawFormat.Alignment = StringAlignment.Near;

    // Draw string to screen.
    e.Graphics.DrawString(drawString, drawFont, drawBrush, drawRect, drawFormat);
    e.Graphics.DrawString(drawBulstat, drawFont, drawBrush, drawRect_1, drawFormat);
    e.Graphics.DrawString(drawRKO, drawFont, drawBrush, drawRect_2, drawFormat);
    e.Graphics.DrawString(drawStart_date, drawFont, drawBrush, drawRect_3, drawFormat);
    e.Graphics.DrawString(drawTo, drawFont, drawBrush, drawRect_4, drawFormat);
    e.Graphics.DrawString(drawOsnovanie, drawFont, drawBrush, drawRect_5, drawFormat);
    e.Graphics.DrawString(drawStringSum, drawFont, drawBrush, drawRect_6, drawFormat);
    e.Graphics.DrawString(drawUser, drawFont, drawBrush, drawRect_7, drawFormat);
    e.Graphics.DrawString(drawDriver_1, drawFont, drawBrush, drawRect_8, drawFormat);
    //Втори ордер
    e.Graphics.DrawString(drawString, drawFont, drawBrush, drawRect_9, drawFormat);
    e.Graphics.DrawString(drawBulstat, drawFont, drawBrush, drawRect_10, drawFormat);
    e.Graphics.DrawString(drawRKO, drawFont, drawBrush, drawRect_11, drawFormat);
    e.Graphics.DrawString(drawStart_date, drawFont, drawBrush, drawRect_12, drawFormat);
    e.Graphics.DrawString(drawTo, drawFont, drawBrush, drawRect_13, drawFormat);
    e.Graphics.DrawString(drawOsnovanie, drawFont, drawBrush, drawRect_14, drawFormat);
    e.Graphics.DrawString(drawStringSum, drawFont, drawBrush, drawRect_15, drawFormat);
    e.Graphics.DrawString(drawUser, drawFont, drawBrush, drawRect_16, drawFormat);
    e.Graphics.DrawString(drawDriver_1, drawFont, drawBrush, drawRect_17, drawFormat);
    //Трети ордер
    e.Graphics.DrawString(drawString, drawFont, drawBrush, drawRect_18, drawFormat);
    e.Graphics.DrawString(drawBulstat, drawFont, drawBrush, drawRect_19, drawFormat);
    e.Graphics.DrawString(drawRKO, drawFont, drawBrush, drawRect_20, drawFormat);
    e.Graphics.DrawString(drawStart_date, drawFont, drawBrush, drawRect_21, drawFormat);
    e.Graphics.DrawString(drawTo, drawFont, drawBrush, drawRect_22, drawFormat);
    e.Graphics.DrawString(drawOsnovanie, drawFont, drawBrush, drawRect_23, drawFormat);
    e.Graphics.DrawString(drawStringSum, drawFont, drawBrush, drawRect_24, drawFormat);
    e.Graphics.DrawString(drawUser, drawFont, drawBrush, drawRect_25, drawFormat);
    e.Graphics.DrawString(drawDriver_1, drawFont, drawBrush, drawRect_26, drawFormat);
    //Четвърти ордер
    e.Graphics.DrawString(drawString, drawFont, drawBrush, drawRect_27, drawFormat);
    e.Graphics.DrawString(drawBulstat, drawFont, drawBrush, drawRect_28, drawFormat);
    e.Graphics.DrawString(drawRKO, drawFont, drawBrush, drawRect_29, drawFormat);
    e.Graphics.DrawString(drawStart_date, drawFont, drawBrush, drawRect_30, drawFormat);
    e.Graphics.DrawString(drawTo_2, drawFont, drawBrush, drawRect_31, drawFormat);
    e.Graphics.DrawString(drawOsnovanie, drawFont, drawBrush, drawRect_32, drawFormat);
    e.Graphics.DrawString(drawStringSum, drawFont, drawBrush, drawRect_33, drawFormat);
    e.Graphics.DrawString(drawUser, drawFont, drawBrush, drawRect_34, drawFormat);
    e.Graphics.DrawString(drawDriver_2, drawFont, drawBrush, drawRect_35, drawFormat);

}
Posted
Comments
Charan_Kumar 3-Apr-14 6:16am    
had you tried e.HasMorePages = true;
Petar Bushev 3-Apr-14 6:34am    
i don't use this one before I need a litle example in this code how to use e.hasMore pages

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900