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

VB.NET Discussion :

Imprimer visu pour debutant


Sujet :

VB.NET

  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    386
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 386
    Par défaut Imprimer visu pour debutant
    Voila grace a vos conseils j'arrive a faire pas mal de manips ! grand merci a vous !
    Mon programme fonctionne ainsi, quand on execute le .exe, sa ouvre une fenetre windows avec sur la partie gauche different champ a renseigner, et au fur et a mesur que l'utilisateur remplis ces champs , il y a sur la partie droite un visuel de ces choix.
    Mainteant j'aimerais offrir la possibilité a l'utilisateur d'imprimer cex choix , donc d'imprimer le visi de la prti droite.
    Cela est t'il compliquer a mettre en place ? et par quoi dois je commencer ?
    attention je suis un gros débutant ! ^^
    D'abord je place un bouton "imprimeré qui quand la personne click dessus sa imprime tels partie de la fenetre.
    Exemple : onclick"imprimer" , print tel parti de l'ecran.
    Cela est 'il possible ?

  2. #2
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    229
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2008
    Messages : 229

  3. #3
    Membre éclairé
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    386
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 386
    Par défaut
    Ok je vient de parcourir le fichier mais apparemennt il agit sur la recup de sonné pour l'imprimer, dans mon cas la visu est deja faite, n'est'il pas possible de faire une commande qui imprime tels parti de la fenetre ?

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    229
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2008
    Messages : 229
    Par défaut
    bonjour,

    les elements PrintDocument et PrintDialog sont la pour t'aider

  5. #5
    Membre Expert Avatar de OhMonBato
    Homme Profil pro
    Inscrit en
    Mars 2007
    Messages
    2 660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2007
    Messages : 2 660
    Par défaut
    Dans l'aide cherche "Imprimer un formulaire", tu y trouveras un exemple d'impression d'un formulaire complet. Tu auras juste a adapter un peu le code pour n'imprimer qu'une partie de ton formulaire.

  6. #6
    Membre éclairé
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    386
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 386
    Par défaut
    je cherche ce fameux post mais apparement je ne le trouve pas, tu connaitrais l'auteur par hasard ?

  7. #7
    Membre éclairé
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    386
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 386
    Par défaut
    Citation Envoyé par quentincabo Voir le message
    bonjour,

    les elements PrintDocument et PrintDialog sont la pour t'aider
    Ok je vais essayer aussi, j'ai lu qu'on peux utiliser aussi Printform ?
    Je precise je suis sur VB2008

    j'ai trouver ceci
    http://msdn.microsoft.com/library/de...intingForm.asp
    apparement sa imprime une form, mais moi j'ai plusieurs form, serait'il possible a ce moment de creer une form qui "englobe" toutes les autres, ou bien je fais fausse route

  8. #8
    Membre Expert Avatar de OhMonBato
    Homme Profil pro
    Inscrit en
    Mars 2007
    Messages
    2 660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2007
    Messages : 2 660
    Par défaut
    Citation Envoyé par OhMonBato Voir le message
    Dans l'aide cherche "Imprimer un formulaire", tu y trouveras un exemple d'impression d'un formulaire complet. Tu auras juste a adapter un peu le code pour n'imprimer qu'une partie de ton formulaire.
    Je ne parlais pas d'un post mais de l'aide de VB2008

  9. #9
    Membre éclairé
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    386
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 386
    Par défaut
    Ok je viens de trouver !! :-)
    tu parle bien de ce bout de code ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            ' Hide the print button
            Button1.Visible = False
            ' Set the PrintAction to display a Print Preview dialog
            PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
            ' Print a copy of the form
            PrintForm1.Print()
            ' Restore the print button
            Button1.Visible = True
        End Sub

  10. #10
    Membre éclairé
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    386
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 386
    Par défaut
    Oula merci beaucoup ca marche presque comme je veux, sa imprime tout mon ecran, or moi je voudrais qu'il imprime la partie de droite, cela est 'il possible ?

  11. #11
    Membre Expert Avatar de OhMonBato
    Homme Profil pro
    Inscrit en
    Mars 2007
    Messages
    2 660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2007
    Messages : 2 660
    Par défaut
    De celui la tres exactement :

    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
     
    Imports System
    Imports System.Windows.Forms
    Imports System.Drawing
    Imports System.Drawing.Printing
    Public Class Form1
        Inherits Form
        Private WithEvents printButton As New Button
        Private WithEvents printDocument1 As New PrintDocument
        Public Sub New()
            printButton.Text = "Print Form"
            Me.Controls.Add(printButton)
        End Sub
        Dim memoryImage As Bitmap
        Private Sub CaptureScreen()
            Dim myGraphics As Graphics = Me.CreateGraphics()
            Dim s As Size = Me.Size
            memoryImage = New Bitmap(s.Width, s.Height, myGraphics)
            Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
            memoryGraphics.CopyFromScreen(Me.Location.X, Me.Location.Y, 0, 0, s)
        End Sub
        Private Sub printDocument1_PrintPage(ByVal sender As System.Object, _
           ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles _
           printDocument1.PrintPage
            e.Graphics.DrawImage(memoryImage, 0, 0)
        End Sub
        Private Sub printButton_Click(ByVal sender As System.Object, ByVal e As _
           System.EventArgs) Handles printButton.Click
            CaptureScreen()
            printDocument1.Print()
        End Sub
        Public Shared Sub Main()
            Application.Run(New Form1())
        End Sub
    End Class

  12. #12
    Membre éclairé
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    386
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 386
    Par défaut
    EN testant la 2eme methode, je recois ce message :
    'Public Sub New()' dans le type généré par le concepteur 'app1.Form1' doit appeler la méthode InitializeComponent. C:\Users\lolo\Documents\Visual Studio 2008\Projects\app2\app1\Form1.vb
    Donc un objet nommé New ?

    J'arrive mieux a manip le premier code, je pourrais l'adapter popur imprimer tel partie de ma fenetre ?

    Apres quelques Modifications du 2eme code, j'arrive a faire exécuter l'apllication sans "bug", mais aucune option pour imprimer donc j'ai du rater une étape , j'ai coller ce bout de code tout au debut de mon script :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    Imports System
    Imports System.Windows.Forms
    Imports System.Drawing
    Imports System.Drawing.Printing
    Puis vient les different label combo box de mon formulaire, et a la fin j'ai coller ceci :
    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
     
    Public Class Form1
            Inherits Form
            Private WithEvents printButton As New Button
            Private WithEvents printDocument1 As New PrintDocument
            Public Sub New()
                printButton.Text = "Print Form"
                Me.Controls.Add(printButton)
            End Sub
            Dim memoryImage As Bitmap
            Private Sub CaptureScreen()
                Dim myGraphics As Graphics = Me.CreateGraphics()
                Dim s As Size = Me.Size
                memoryImage = New Bitmap(s.Width, s.Height, myGraphics)
                Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
                memoryGraphics.CopyFromScreen(Me.Location.X, Me.Location.Y, 0, 0, s)
            End Sub
            Private Sub printDocument1_PrintPage(ByVal sender As System.Object, _
               ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles _
               printDocument1.PrintPage
                e.Graphics.DrawImage(memoryImage, 0, 0)
            End Sub
            Private Sub printButton_Click(ByVal sender As System.Object, ByVal e As  _
               System.EventArgs) Handles printButton.Click
                CaptureScreen()
                printDocument1.Print()
            End Sub
            Public Shared Sub Main()
                Application.Run(New Form1())
            End Sub
        End Class
    Malgres aucune erreure, aucun bouton "print".
    Je dois certainement rajouter un élément de la boite outils je suppose ?
    A quoi correspond le private sub "new" ?

  13. #13
    Membre éclairé
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    386
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 386
    Par défaut
    Personne aurait une idee de ma mauvaise manip ? ( je sais j'ai pas beaucoup de notion donc j'interprete mal le truc)

Discussions similaires

  1. Cherche cours Linux pour débutant
    Par Le Pharaon dans le forum Applications et environnements graphiques
    Réponses: 11
    Dernier message: 24/11/2005, 10h52
  2. [Plugin]plugin graphique pour debutant
    Par vijeo dans le forum Eclipse Java
    Réponses: 4
    Dernier message: 23/11/2005, 12h37
  3. Problème pour debuter avec glut
    Par ismael14 dans le forum GLUT
    Réponses: 2
    Dernier message: 26/07/2004, 11h37
  4. [sql] update pour debutant
    Par zebulix13 dans le forum Langage SQL
    Réponses: 3
    Dernier message: 11/06/2004, 16h45
  5. [langage] Renseignement pour débuter sur perl
    Par freeshman dans le forum Langage
    Réponses: 2
    Dernier message: 30/04/2004, 00h47

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