IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++/CLI Discussion :

Impression qui prend plus qu'une page


Sujet :

C++/CLI

  1. #1
    Membre régulier
    Inscrit en
    Juillet 2007
    Messages
    124
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 124
    Points : 71
    Points
    71
    Par défaut Impression qui prend plus qu'une page
    Bonjours,

    Je vous soumet mon code car je comprend pas pourquoi je ne suis pas capable imprimer sur 2 pages. il imprime la 2ieme page par dessus la 1 ière page. Pourquoi?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    private: System::Void printDocument1_PrintPage(System::Object^  sender, System::Drawing::Printing::PrintPageEventArgs^  e) 
    		 {
    			Pen^ blackPen = gcnew Pen( Color::Black,1.0f );
    			System::Drawing::Font ^FT1 = gcnew System::Drawing::Font( this->Font,FontStyle::Bold );
    			System::Drawing::Font ^FT2 = gcnew System::Drawing::Font( this->Font,FontStyle::Regular );
    			int TabPage = tabControl1->SelectedIndex;
    			array<Control ^> ^dataGridViewATrouver = tabControl1->Controls->Find(String::Format("dataGridView{0}",TabPage), true);
    			DataGridView ^DGV = safe_cast<DataGridView^>(dataGridViewATrouver[0]);
    			int Rows = DGV->RowCount;
    			e->Graphics->DrawString("Inventaire "+tabControl1->TabPages[TabPage]->Text,label33->Font,Brushes::Black,float::Parse((300).ToString()),float::Parse((2).ToString()));
    			e->Graphics->DrawString("Code ",FT1,Brushes::Black,float::Parse((17).ToString()),float::Parse((40).ToString()));
    			e->Graphics->DrawString("CUP",FT1,Brushes::Black,float::Parse((134).ToString()),float::Parse((40).ToString()));
    			e->Graphics->DrawString("Description de l'article",FT1,Brushes::Black,float::Parse((362).ToString()),float::Parse((40).ToString()));
    			e->Graphics->DrawString("Quantitées",FT1,Brushes::Black,float::Parse((717).ToString()),float::Parse((40).ToString()));
    			Rectangle rect1 = Rectangle(1,39,100,14);
    			Rectangle rect2 = Rectangle(101,39,100,14);
    			Rectangle rect3 = Rectangle(201,39,500,14);
    			Rectangle rect4 = Rectangle(701,39,100,14);
    			e->Graphics->DrawRectangle( blackPen, rect1 );
    			e->Graphics->DrawRectangle( blackPen, rect2 );
    			e->Graphics->DrawRectangle( blackPen, rect3 );
    			e->Graphics->DrawRectangle( blackPen, rect4 );
    			int y = 0;
    			int EmpY = 0;
    			for (int i=0; i<Rows; i++)
    			{
    				if ( EmpY > 1050)
    				{
    					e->HasMorePages = true;
    					y =0;
    					EmpY = 0;
    					e->Graphics->DrawString("Inventaire "+tabControl1->TabPages[TabPage]->Text,label33->Font,Brushes::Black,float::Parse((300).ToString()),float::Parse((2).ToString()));
    					e->Graphics->DrawString("Code ",FT1,Brushes::Black,float::Parse((17).ToString()),float::Parse((40).ToString()));
    					e->Graphics->DrawString("CUP",FT1,Brushes::Black,float::Parse((134).ToString()),float::Parse((40).ToString()));
    					e->Graphics->DrawString("Description de l'article",FT1,Brushes::Black,float::Parse((362).ToString()),float::Parse((40).ToString()));
    					e->Graphics->DrawString("Quantitées",FT1,Brushes::Black,float::Parse((717).ToString()),float::Parse((40).ToString()));
    					Rectangle rect1 = Rectangle(1,39,100,14);
    					Rectangle rect2 = Rectangle(101,39,100,14);
    					Rectangle rect3 = Rectangle(201,39,500,14);
    					Rectangle rect4 = Rectangle(701,39,100,14);
    					e->Graphics->DrawRectangle( blackPen, rect1 );
    					e->Graphics->DrawRectangle( blackPen, rect2 );
    					e->Graphics->DrawRectangle( blackPen, rect3 );
    					e->Graphics->DrawRectangle( blackPen, rect4 );
    				}
    				else e->HasMorePages = false;
    				DataGridViewRow ^row = DGV->Rows[i];
    				e->Graphics->DrawString(Convert::ToString(row->Cells[0]->Value),FT2,Brushes::Black,float::Parse((2).ToString()),float::Parse((y*14+54).ToString()));
    				e->Graphics->DrawString(Convert::ToString(row->Cells[1]->Value),FT2,Brushes::Black,float::Parse((102).ToString()),float::Parse((y*14+54).ToString()));
    				e->Graphics->DrawString(Convert::ToString(row->Cells[2]->Value),FT2,Brushes::Black,float::Parse((202).ToString()),float::Parse((y*14+54).ToString()));
    				e->Graphics->DrawString(Convert::ToString(row->Cells[3]->Value),FT2,Brushes::Black,float::Parse((702).ToString()),float::Parse((y*14+54).ToString()));
    				rect1 = Rectangle(1,y*14+53,100,14);
    				rect2 = Rectangle(101,y*14+53,100,14);
    				rect3 = Rectangle(201,y*14+53,500,14);
    				rect4 = Rectangle(701,y*14+53,100,14);
    				e->Graphics->DrawRectangle( blackPen, rect1 );
    				e->Graphics->DrawRectangle( blackPen, rect2 );
    				e->Graphics->DrawRectangle( blackPen, rect3 );
    				e->Graphics->DrawRectangle( blackPen, rect4 );
    				EmpY = y*14+54;
    				y++;
    			}
     
     
    		}
    Merci pour votre aide

  2. #2
    Membre régulier
    Inscrit en
    Juillet 2007
    Messages
    124
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 124
    Points : 71
    Points
    71
    Par défaut
    3 jours que je cherche et comprend toujours pas est-ce qu'il y a quelqu'un pour m'aider s.v.p

    Merci d'avance

  3. #3
    Membre régulier
    Profil pro
    Développeur informatique
    Inscrit en
    Février 2006
    Messages
    76
    Détails du profil
    Informations personnelles :
    Âge : 64
    Localisation : France, Eure et Loir (Centre)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 76
    Points : 96
    Points
    96
    Par défaut
    Salut


    à mon avis "e->HasMorePages = true;" ne doit pas être dans la boucle de remplissage de ta page. J'ai l'impression que là où tu l'a placée l'instruction ne sert à rien. Ce qui est pris en charge dans boucle ça n'est que le remplissage des lignes de texte en changeant leur position. Donc il est normal que tu aies les deux pages superposées.

    Selon MSDN, il faut que tu dessines tes lignes jusqu'au nombre maximal de lignes pouvant être imprimées sur une page, puis la limite atteinte ton code test e->HasMorePages et si true renvoie un évènement PrintPage.

    http://msdn.microsoft.com/en-us/libr...ent.print.aspx

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 18
    Dernier message: 02/05/2013, 16h34
  2. Grand tableau qui prend plus d'une page
    Par Rabie de OLEP dans le forum Tableaux - Graphiques - Images - Flottants
    Réponses: 1
    Dernier message: 03/01/2007, 22h22
  3. [impression] imprimer les résultats d'une page jsp
    Par Lady_jade dans le forum Servlets/JSP
    Réponses: 9
    Dernier message: 24/03/2006, 11h59
  4. Ouvrir une fenêtre pop up en plus d'une page normale
    Par Satination dans le forum Balisage (X)HTML et validation W3C
    Réponses: 3
    Dernier message: 17/08/2005, 10h28

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo