Séléction des imprimantes dans la mise en page

Résolu
hanadakia Messages postés 43 Date d'inscription mercredi 21 mai 2014 Statut Membre Dernière intervention 30 mai 2018 - Modifié le 13 nov. 2017 à 21:30
hanadakia Messages postés 43 Date d'inscription mercredi 21 mai 2014 Statut Membre Dernière intervention 30 mai 2018 - 14 nov. 2017 à 15:15
Bonjour tout le monde,



Voici le code qui m'affiche ce formulaire. Maintenant je veux ajouter le combo qui contient les noms des imprimantes
Dim pgprint As PageSettings
pgprint = New PageSettings()
Dim configprint As PrinterSettings
configprint = New PrinterSettings()
dlgpgsetup.PageSettings() = pgprint
dlgpgsetup.AllowPrinter = True
dlgpgsetup.PrinterSettings = configprint
dlgpgsetup.ShowDialog()


EDIT : Ajout des balises de code (la coloration syntaxique).

Explications disponibles ici :ICI

Merci d'y penser dans tes prochains messages.
Jordane45


Merci d'avance

3 réponses

Whismeril Messages postés 19022 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 17 avril 2024 656
13 nov. 2017 à 17:50
Bonjour
c'est quoi dlgpgsetup?

0
hanadakia Messages postés 43 Date d'inscription mercredi 21 mai 2014 Statut Membre Dernière intervention 30 mai 2018
13 nov. 2017 à 17:55
c'est un contrôle pageSetupDialog que j'ai ajouté au formulaire
0
cs_Le Pivert Messages postés 7903 Date d'inscription jeudi 13 septembre 2007 Statut Contributeur Dernière intervention 11 mars 2024 137
13 nov. 2017 à 18:07
Bonjour,

comme ceci:

Imports System.Drawing.Printing
Public Class Form1
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        For i = 0 To PrinterSettings.InstalledPrinters.Count - 1
            ComboBox1.Items.Add(PrinterSettings.InstalledPrinters.Item(i))
            ComboBox1.SelectedIndex = 0
        Next
    End Sub
End Class

0
hanadakia Messages postés 43 Date d'inscription mercredi 21 mai 2014 Statut Membre Dernière intervention 30 mai 2018
13 nov. 2017 à 18:14
Dans mon cas, comment je peux insérer un combo au niveau d'un contrôle pageSetupDialog ?
0
Whismeril Messages postés 19022 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 17 avril 2024 656
13 nov. 2017 à 19:39
Tu ne peux c’est un formulaire windows.
Si tu veux un formulaire avec ce combobox, à toi de l'écrire entièrement
0
cs_Le Pivert Messages postés 7903 Date d'inscription jeudi 13 septembre 2007 Statut Contributeur Dernière intervention 11 mars 2024 137 > Whismeril Messages postés 19022 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 17 avril 2024
Modifié le 13 nov. 2017 à 19:56
Salut Whismeril,

cela existe d'une autre manière avec un bouton supplémentaire, mais le code donné ne fonctionne pas!

Voir page 12 du PDF:

http://docplayer.fr/13029621-Imprimer-avec-vb-net-2005-1-introduction-3-concepts-generaux-3.html
0
Whismeril Messages postés 19022 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 17 avril 2024 656 > cs_Le Pivert Messages postés 7903 Date d'inscription jeudi 13 septembre 2007 Statut Contributeur Dernière intervention 11 mars 2024
13 nov. 2017 à 20:31
Oui, mais on reste bien dans les formulaires de windows.

Pour le code, c'est du VB 2005, ça a du changer depuis.
J'y jette un oeil.
0
Whismeril Messages postés 19022 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 17 avril 2024 656 > Whismeril Messages postés 19022 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 17 avril 2024
13 nov. 2017 à 20:53
Il semble qu'à l'époque de la sortie de Vista, les développeurs Microsoft aient décidé que ce formulaire ne donnait plus accès au choix des imprimantes.
Il faut utiliser un PrintDialog

        Dim Doc As New PrintDocument
        Dim PageSetup As New PrintDialog

        With PageSetup
            .AllowSomePages = True
            .Document = Doc
            .ShowDialog()
        End With


        With Me.TextBox6
            .Text = Doc.PrinterSettings.PrinterName & Environment.NewLine
            .Text = .Text & "Nb de copies : " & Doc.PrinterSettings.Copies.ToString & Environment.NewLine
            .Text = .Text & "Assemblées : " & Doc.PrinterSettings.Collate.ToString & Environment.NewLine
            .Text = .Text & "Couleur : " & Doc.DefaultPageSettings.Color.ToString & Environment.NewLine
            .Text = .Text & "Orientation : " & If(Doc.DefaultPageSettings.Landscape, "Paysage", "Portrait") & Environment.NewLine
            .Text = .Text & "Format : " & Doc.DefaultPageSettings.PaperSize.ToString & Environment.NewLine
        End With


Source
https://social.msdn.microsoft.com/Forums/windows/en-US/29b17b85-3c33-4eb1-9a8c-84f1360f7347/pagesetupdialogallowprinter-true-not-work-in-windows-vista?forum=winforms
0
Rejoignez-nous