Bonjour tout le monde!!!
Je cherche à imprimer des données dans une listBox avec le code ci-dessous quand je lance l'impression il m'imprime une page blanche.
Je ne sais pas trop d'ou viens le problème quequ'un veux bien m'aider STP.
private
: System::Void button6_Click(System::Object * sender, System::EventArgs * e)
{
printDialog1 = new PrintDialog();
printDocument1 = new System::Drawing::Printing::PrintDocument();
/*
Et voila pour l'impression de la listbox
*/
printDialog1->Document = printDocument1;
if(printDialog1->ShowDialog()==DialogResult::OK)
{
printDocument1->Print();
}
}
private
: System::Void printDocument1_QueryPageSettings(System::Object * sender, System::Drawing::Printing::PrintPageEventArgs * e)
{
//Do nothing
}
private
: System::Void printDocument1_PrintPage(System::Object * sender, System::Drawing::Printing::PrintPageEventArgs * e)
{
System::Drawing::Font* drawFont = new System::Drawing::Font("Arial", 10);
SolidBrush* maBrush = new SolidBrush(Color::Black);
int u= 20;
int nombreitem;
nombreitem = listBox1->Items->Count;
for (int x = 0; x < nombreitem; x++)
{
listBox1->SetSelected(x,true);
e->Graphics->DrawString(listBox1->Text,drawFont,maBrush, 10, (float)u); // role de u assez obscur...
u= u+20;
// theoriquement, remplit la page element par element
}
}