|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Printing in VB.NetThe following seemed so simple in VB6 (CD1 is CommonDialogue1)
CD1.CancelError = True CD1.ShowPrinter Printer.PaintPicture ActiveForm.Picture1.Picture, 720, 720 to print the image in a picturebox. I have spent hours Googling to try and fathom out how to do it in VB.Net (2005). Surely it doesn't take all the code I've seen? -Jerry "Jerry Spence1" <jerry.spe***@somewhere.com>'s wild thoughts were released on Wed, 23 Aug 2006 01:27:51 +0100 bearing thefollowing fruit: Show quoteHide quote >The following seemed so simple in VB6 (CD1 is CommonDialogue1) Well the VB6 code you quote isn't as straight forward as it> > CD1.CancelError = True > CD1.ShowPrinter > Printer.PaintPicture ActiveForm.Picture1.Picture, 720, 720 > >to print the image in a picturebox. > >I have spent hours Googling to try and fathom out how to do it in VB.Net >(2005). Surely it doesn't take all the code I've seen? > >-Jerry > seems. In your example the first two lines have no effect on the third, and more code is required to determine which printer the user selected. Jan Hyde (VB MVP) -- They considered their silver anniversary a sterling event. (Jumble) Jerry Spence1 wrote:
Show quoteHide quote > The following seemed so simple in VB6 (CD1 is CommonDialogue1) Don't worry - it still is, but like you I have found that just about > > CD1.CancelError = True > CD1.ShowPrinter > Printer.PaintPicture ActiveForm.Picture1.Picture, 720, 720 > > to print the image in a picturebox. > > I have spent hours Googling to try and fathom out how to do it in VB.Net > (2005). Surely it doesn't take all the code I've seen? > > -Jerry > > Hello Jerry, every explanation I read for doing things in VB.Net seems so complicated - most times it just isn't! (I'd hate to see some of the code that people are producing!!!) The simplest way I could provide the functionality in VB.Net (2005) as in your example is - 1. Place a PrintDialog Control onto your Form. 2. Place a PrintDocument Control onto your Form. 3. Place a Button Control onto your Form. 4. Place a PictureBox Control onto your Form. 5. In the Button Click Event write - If PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then PictureBox1.Image = System.Drawing.Image.FromFile("C:\Image.jpg") PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings PrintDocument1.Print() End If 5. In the PrintDocument1 PrintPage Event write - e.Graphics.DrawImage(PictureBox1.Image, New Point(100, 100)) That's it!! While this is not very elegant, it does provide the ability to print whatever image is contained in the PictureBox in the same manner that your code would provide. ShaneO There are 10 kinds of people - Those who understand Binary and those who don't.
VB Express SQL Express Remote Connection
Trouble with "Process's" please help! .NET equivilant of isnumeric copy HTML information Datagridview Search? Merging Datasets Incorrect behavior of IIf in VB.NET (.NET Framework 1.1 SP1) Text missing from RadioButtons in Groupbox can I use Imports with a VB2005 class namespace? Trouble Instanciating Structures |
|||||||||||||||||||||||