Impression des données a partir du formulaire

achzouba - 13 mai 2013 à 12:41
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 - 18 mai 2013 à 22:50
Bonjour


j'ai realisé une intreface graphique qui contient bouceaup plus des textbox
l'utilusateur final va remplir les textbox et clique sur un bouton d'impression pour imprimer le contenu des textbox

le brobleme est que je n'arrive pas a definir les dimention de la page pour que les text imprimé soit a la position que je veut

s'il vous plé aidez mois. j'avais essayer de modifier les paramettre dans l'instruction newfont mais ca ne marche plus




Imports System.Drawing.Printing

Public Class Form1



Inherits System.Windows.Forms.Form



Dim pd As New PrintDocument 'Assumes the default printer


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

AddHandler pd.PrintPage, AddressOf Me.Pd_PrintPage

End Sub


Private Sub Pd_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)


e.Graphics.DrawString(TextBox1.Text, New Font("Arial", 9, FontStyle.Bold), Brushes.Black, 178.87, 178.87)
e.Graphics.DrawString(TextBox2.Text, New Font("Arial", 9, FontStyle.Bold), Brushes.Black, 205.87, 205.87)
e.Graphics.DrawString(TextBox3.Text, New Font("Arial", 9, FontStyle.Bold), Brushes.Black, 612, 370.8)



End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click




' Dim psDlg As New PageSetupDialog

' Dim LePageSettings As New PageSettings

' psDlg.PageSettings = LePageSettings

' psDlg.ShowDialog()

' pd.DefaultPageSettings = LePageSettings


Dim dlg As New PrintDialog

dlg.Document = pd

Dim result As DialogResult = dlg.ShowDialog()

If (result = System.Windows.Forms.DialogResult.OK) Then

pd.Print()

End If

'pour vider le textbox
TextBox1.Clear()

End Sub


Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

End Sub

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged

End Sub

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

End Sub

Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint

End Sub

Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click

End Sub

Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged

End Sub

Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged

End Sub

Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged

End Sub

Private Sub TextBox7_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox7.TextChanged

End Sub

Private Sub TextBox8_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox8.TextChanged

End Sub


Private Sub Label15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label15.Click

End Sub


End Class

10 réponses

Utilisateur anonyme
13 mai 2013 à 19:25
Salut,

Sachant que 1 centimètre sur ta feuille de papier A4 représente 28.34645669 en coordonnées point, tu dois faire une simple règle de trois.

Exemple : Tu veux placer un texte à 3 centimètres de bord gauche et à 5 centimètres depuis le haut de ta feuille, tu auras : x 3 x 28.34645669 soit x 85. Et y = 5 x 28.34645669 soit y = 142.

Ta ligne de code deviendra :
e.Graphics.DrawString(TextBox1.Text, New Font("Arial", 9, FontStyle.Bold), Brushes.Black, new point(85, 142)) 
0
bonjour banana32 et merci pour votre répense

SVP vous pouvez me dire est ce qu'il y a des erreurs dans mon code sources

est ce qu'il est bien ecrit


merci d'avance mon amis
0
Utilisateur anonyme
15 mai 2013 à 12:53
Ton code n'est pas indenté ni placé entre les balises de colorations de code. (3eme icône depuis la droite)
En gros, je ne lis pas les codes en noir et blanc surtout quand il y en a beaucoup
0
Imports System.Drawing.Printing 

Public Class Form1 



Inherits System.Windows.Forms.Form 



Dim pd As New PrintDocument 'Assumes the default printer 
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
oui tu as raison


Imports System.Drawing.Printing 

Public Class Form1 



Inherits System.Windows.Forms.Form 



Dim pd As New PrintDocument 'Assumes the default printer 


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
AddHandler pd.PrintPage, AddressOf Me.Pd_PrintPage 

End Sub 


Private Sub Pd_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
 

e.Graphics.DrawString(TextBox1.Text, New Font("Arial", 9, FontStyle.Bold), Brushes.Black, 178.87, 178.87)
 e.Graphics.DrawString(TextBox2.Text, New Font("Arial", 9, FontStyle.Bold), Brushes.Black, 205.87, 205.87)
 e.Graphics.DrawString(TextBox3.Text, New Font("Arial", 9, FontStyle.Bold), Brushes.Black, 612, 370.8)
 


End Sub 


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 



' Dim psDlg As New PageSetupDialog 

' Dim LePageSettings As New PageSettings 

' psDlg.PageSettings = LePageSettings 

' psDlg.ShowDialog() 

' pd.DefaultPageSettings = LePageSettings 


Dim dlg As New PrintDialog 

dlg.Document = pd 

Dim result As DialogResult = dlg.ShowDialog() 

If (result = System.Windows.Forms.DialogResult.OK) Then 

pd.Print() 

End If 

'pour vider le textbox 
TextBox1.Clear() 

End Sub 


Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
 
End Sub 

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
 
End Sub 

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
 
End Sub 

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
 
End Sub 

Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
 
End Sub 

Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
 
End Sub 

Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
 
End Sub 

Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged
 
End Sub 

Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged
 
End Sub 

Private Sub TextBox7_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox7.TextChanged
 
End Sub 

Private Sub TextBox8_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox8.TextChanged
 
End Sub 


Private Sub Label15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label15.Click
 
End Sub 


End Class





c'est en couleur maintenant
0
j'avais essayé la regle que tu as m donné mais toujours je trouves des décalage,


/////Sachant que 1 centimètre sur ta feuille de papier A4 représente 28.34645669 en coordonnées point, tu dois faire une simple règle de trois.

Exemple : Tu veux placer un texte à 3 centimètres de bord gauche et à 5 centimètres depuis le haut de ta feuille, tu auras : x 3 x 28.34645669 soit x 85. Et y = 5 x 28.34645669 soit y = 142. //////


merci pour votre aide et désolé pour mes long question ...
0
Utilisateur anonyme
15 mai 2013 à 20:12
j'avais essayé la regle que tu as m donné mais toujours je trouves des décalage

Tu as raison, ma solution ne fonctionnera pas car il faut prendre en compte la résolution de l'écran (g.DpiX et g.DpiY). Essaie de trouver des exemples sur le net. Pas trop de temps de t'aider ce soir désolé.
0
Utilisateur anonyme
15 mai 2013 à 20:16
Tu peux t'inspirer de cette discussion où j'avais déjà répondu à côté d'ailleurs
0
merci beaucoup mes amis pour vos aides
0
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 211
18 mai 2013 à 22:50
Bonsoir,
Et la résolution de l'imprimante elle-même ? VB.Net la gère spontanément ?


________________________
Réponse exacte ? => "REPONSE ACCEPTEE" facilitera les recherches.
Pas d'aide en ligne installée ? => ne comptez pas sur moi pour simplement répéter son contenu. Je n'interviendrai que si nécessité de la compléter.
0
Rejoignez-nous