begin process at 2012 02 14 08:25:08
  Trouver un code source :
 
dans
 
Accueil > Forum > 

VB.NET et VB 2005

 > 

Divers

 > 

Débutants

 > 

pagesetup


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

pagesetup

dimanche 6 janvier 2008 à 19:31:51 | pagesetup

DanMor498

quelqu'un peut me dir pourquoi ca fonctionne pas  ce code

Habituellement lorsque que je clique pageset cela doit fonction ouvrir la boite de dialog de printsetupdialog et dans la liste source devrait indiquer soit automatique ou autre source mais la rien  et ca plante quand je ouvre propritées de limprimant et tout sort d'indication d erreur apparait et la boite de dialog printpreview vien folle et apparait de travers la boite de texte
 est tout defaites.

-------------------------------------------------------------------------------------------------

Imports

System.Drawing.Printing
PublicClass Form1
PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
RichTextBox1.Text =
"Programmers have undergone a major change in many years of programming various machines. For example, what could take days to create an " & _
"application in other programming languages like C, C++ could be done in hours with " & _
"Visual Basic. Visual Basic provides many interesting sets of tools to aid us in " & _
"building exciting applications. Visual Basic provides these tools to make our " & _
"life far more easier because all the real hard code is already written for us."
'filling the richtextbox with some text that can be used readily
EndSub

PrivateSub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click
If PrintDialog1.ShowDialog = DialogResult.OK Then
'showDialog method makes the dialog box visible at run time
PrintDocument1.Print()
EndIf
EndSub

PrivateSub PrintPreviewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreviewToolStripMenuItem.Click
Try
PrintPreviewDialog1.ShowDialog()
Catch es As Exception
MessageBox.Show(es.Message)
EndTry
EndSub

PrivateSub PageSetupToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PageSetupToolStripMenuItem.Click
With PageSetupDialog1
.PageSettings = PrintDocument1.DefaultPageSettings
EndWith
Try
If PageSetupDialog1.ShowDialog = DialogResult.OK Then
PrintDocument1.DefaultPageSettings = PageSetupDialog1.PageSettings
EndIf
Catch es As Exception
messageBox.Show(es.Message)
EndTry
EndSub

PrivateSub PPControlToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PPControlToolStripMenuItem.Click
Try
PrintPreviewControl1.Document = PrintDocument1
Catch es As Exception
MessageBox.Show(es.Message)
EndTry
EndSub

PrivateSub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
'PrintPage is the foundational printing event. This event gets fired for every
' page that will be printed
Static intCurrentChar As Int32

' declaring a static variable to hold the position of the last printed char
Dim font AsNew Font("Verdana", 14)

' initializing the font to be used for printing
Dim PrintAreaHeight, PrintAreaWidth, marginLeft, marginTop As Int32
With PrintDocument1.DefaultPageSettings

' initializing local variables that contain the bounds of the printing area rectangle
PrintAreaHeight = .PaperSize.Height - .Margins.Top - .Margins.Bottom
PrintAreaWidth = .PaperSize.Width - .Margins.Left - .Margins.Right

' initializing local variables to hold margin values that will serve
' as the X and Y coordinates for the upper left corner of the printing
' area rectangle.

marginLeft = .Margins.Left
marginTop = .Margins.Top

' X and Y coordinate
EndWith
If PrintDocument1.DefaultPageSettings.Landscape Then
Dim intTemp As Int32
intTemp = PrintAreaHeight
PrintAreaHeight = PrintAreaWidth
PrintAreaWidth = intTemp

' if the user selects landscape mode, swap the printing area height and width
EndIf
Dim intLineCount As Int32 = CInt(PrintAreaHeight / font.Height)
' calculating the total number of lines in the document based on the height of
' the printing area and the height of the font
Dim rectPrintingArea AsNew RectangleF(marginLeft, marginTop, PrintAreaWidth, PrintAreaHeight)

' initializing the rectangle structure that defines the printing area
Dim fmt AsNew StringFormat(StringFormatFlags.LineLimit)

'instantiating the StringFormat class, which encapsulates text layout information
Dim intLinesFilled, intCharsFitted As Int32
e.Graphics.MeasureString(Mid(RichTextBox1.Text, intCurrentChar + 1), font,
New SizeF(PrintAreaWidth, PrintAreaHeight), fmt, intCharsFitted, intLinesFilled)

' calling MeasureString to determine the number of characters that will fit in
' the printing area rectangle
e.Graphics.DrawString(Mid(RichTextBox1.Text, intCurrentChar + 1), font, Brushes.Black, rectPrintingArea, fmt)

' print the text to the page
intCurrentChar += intCharsFitted

'advancing the current char to the last char printed on this page
'> TextBox1.Text.Length
If intCurrentChar.ToString(e.HasMorePages = True) Then
'HasMorePages tells the printing module whether another PrintPage event should be fired
Else
e.HasMorePages = False
intCurrentChar = 0
EndIf
EndSub
-------------------------------------------------------------------------------------------------

DanMor


Cette discussion est classée dans : system, to, of, byval, printing


Répondre à ce message

Sujets en rapport avec ce message

Obtain specifics System Informations [ par 25230 ] Hello,On W2000 Workstation, I use "msinfo32.exe" to outputs System Information in a text format file (with option/report). The file result is very big Je ne comprend pas cette erreur [ par Rouk ] Bonjour,je developpe en vb.net et voici mon erreur :An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.for high speed bit transfer on usb [ par balek84 ] Hi,I just want to know if i will have some problems with my usb interface. I want to put on usb 4 serial data of 24bits (96bits), 2 serial data of 12b JavaScript vers VB [ par marinmarais ] Bonjour à tous,Permettez-moi de vous présenter mon problème :J'ai récupéré un code source (dans le domaine public ;-)  ) en Javascript permettant de c printpreviewdialog[vbnet] [ par stargates ] Bonjour,Lorsque j'affiche mon printpreviewdialog,celui se met derrière la form d'ou je l'ai appelécode pour la afficher la form Private <FON Jbus et vb.net [ par fcampagne ] Bonjour a tous, Alors voila mon probléme: je voudrais pouvoir envoyer et recevoir des trames via le port série de ma machine pour controler un apparei Calendrie [ par asmaa17 ] Salut à tout,je suis entraint de creer une calandrie,mais j'ai trouve des probléme.je veux quand je sélectionne un mois ,le programme affiche le calen probleme de declaration de list of string [ par niko14 ] Salut tout le monde!voila je voudrais intégrer dans un projet existant des trucs que j'ai fait moi a part!la première chose c'est que je voudrais décl transformation of picture [ par beebrs ] hello -i need to reduce the size of a picture using a VB script without loosing the quality of this picture-how can i integrate photo_ editor with th


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,856 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales