Print Dialog
-
I must be missing something. I tested this in a small stand alone application and it works fine (sample project I downloaded)
Protected Sub PrintFile\_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PrintFile.Click printDialog1.Document = ThePrintDocument 'ThePrintDocument is dfined as System.Drawing.Printing.PrintDocument If printDialog1.ShowDialog() = DialogResult.OK Then Me.ThePrintDocument.Print() End If End Sub 'PrintFile\_Click
I have a sub routine that does the printing as follows:
Protected Sub ThePrintDocument_PrintPage(ByVal sender As Object, ByVal ev As System.Drawing.Printing.PrintPageEventArgs) Handles ThePrintDocument.PrintPage
...
...
...
End Sub 'ThePrintDocument_PrintPageIn my small test app this works perfectly, print dialog shows up, select destination and it calls the print page routine. I then incorporated this into the application I am upgrading and I get the print dialog but when I click OK on the dialog it does not return to call the print event. Any idea what I may have missed? I did notice that if I search the sample project for ThePrintDocument in the sample project I see definitions in a resx file, but I do not understand the resx file or how to use it. I defined by simply entering the definition, should I have dragged something from the toolbox perhaps? Friend WithEvents ThePrintDocument As System.Drawing.Printing.PrintDocument Thanks in advance No-e
-
I must be missing something. I tested this in a small stand alone application and it works fine (sample project I downloaded)
Protected Sub PrintFile\_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PrintFile.Click printDialog1.Document = ThePrintDocument 'ThePrintDocument is dfined as System.Drawing.Printing.PrintDocument If printDialog1.ShowDialog() = DialogResult.OK Then Me.ThePrintDocument.Print() End If End Sub 'PrintFile\_Click
I have a sub routine that does the printing as follows:
Protected Sub ThePrintDocument_PrintPage(ByVal sender As Object, ByVal ev As System.Drawing.Printing.PrintPageEventArgs) Handles ThePrintDocument.PrintPage
...
...
...
End Sub 'ThePrintDocument_PrintPageIn my small test app this works perfectly, print dialog shows up, select destination and it calls the print page routine. I then incorporated this into the application I am upgrading and I get the print dialog but when I click OK on the dialog it does not return to call the print event. Any idea what I may have missed? I did notice that if I search the sample project for ThePrintDocument in the sample project I see definitions in a resx file, but I do not understand the resx file or how to use it. I defined by simply entering the definition, should I have dragged something from the toolbox perhaps? Friend WithEvents ThePrintDocument As System.Drawing.Printing.PrintDocument Thanks in advance No-e
No-e wrote:
should I have dragged something from the toolbox perhaps
In your stand alone application, if you open the Form in the designer and can see a
PrintDocument
component in the Component Tray (at the bottom of the screen), then that was how it was done by the writer of that application. Adding it manually, as you have done, should still work though. If it were me I would delete the manual declaration and use the component from the Printing tab of the toolbox, assuming that that's how the stand alone application did it. Also ensure that the properties are all set the same too.Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
No-e wrote:
should I have dragged something from the toolbox perhaps
In your stand alone application, if you open the Form in the designer and can see a
PrintDocument
component in the Component Tray (at the bottom of the screen), then that was how it was done by the writer of that application. Adding it manually, as you have done, should still work though. If it were me I would delete the manual declaration and use the component from the Printing tab of the toolbox, assuming that that's how the stand alone application did it. Also ensure that the properties are all set the same too.Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
Thanks, I deleted and added them from the toolbox, still a no go. It just does not seem to want to come back from the dialog box. Is there a way to chase down what may be happening after I close the box? No-e
Firstly ensure that all of the properties and events of the
PrintDocument
are the same as in the stand alone application. Do the Same for the PrintDialog. It is distinctly possible that in the stand alone application the PrintDocument.PrintPage event was being handled, but not in your new application. Without handling PrintPage, you won't get any output.Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
I must be missing something. I tested this in a small stand alone application and it works fine (sample project I downloaded)
Protected Sub PrintFile\_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PrintFile.Click printDialog1.Document = ThePrintDocument 'ThePrintDocument is dfined as System.Drawing.Printing.PrintDocument If printDialog1.ShowDialog() = DialogResult.OK Then Me.ThePrintDocument.Print() End If End Sub 'PrintFile\_Click
I have a sub routine that does the printing as follows:
Protected Sub ThePrintDocument_PrintPage(ByVal sender As Object, ByVal ev As System.Drawing.Printing.PrintPageEventArgs) Handles ThePrintDocument.PrintPage
...
...
...
End Sub 'ThePrintDocument_PrintPageIn my small test app this works perfectly, print dialog shows up, select destination and it calls the print page routine. I then incorporated this into the application I am upgrading and I get the print dialog but when I click OK on the dialog it does not return to call the print event. Any idea what I may have missed? I did notice that if I search the sample project for ThePrintDocument in the sample project I see definitions in a resx file, but I do not understand the resx file or how to use it. I defined by simply entering the definition, should I have dragged something from the toolbox perhaps? Friend WithEvents ThePrintDocument As System.Drawing.Printing.PrintDocument Thanks in advance No-e
Hi, if anything, we should see the code related to ThePrintDocument. Are you sure the variable isn't Nothing? You need to debug, i.e. for one make sure ThePrintDocument_PrintPage gets called at all. Are you using any other PrintDocument events? Not that you should, but you could test for PrintDocument.BeginPrint being fired. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
Hi, if anything, we should see the code related to ThePrintDocument. Are you sure the variable isn't Nothing? You need to debug, i.e. for one make sure ThePrintDocument_PrintPage gets called at all. Are you using any other PrintDocument events? Not that you should, but you could test for PrintDocument.BeginPrint being fired. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
I checked the ThePrintDocument_PrintPage is called. Thanks for your help, it turns out that a timer in the background fires perfectly every time in the studio and holds me up. Once I run the compiled version it behaves differently. I have got a nice work around. Interesting, being used to VB6 (from which I am converting) I did not see this type of behavior. The app I am converting used the MScomm32 control quite a bit (serial comms) and I would like to better know how VB6 changes relative to .net as I see these differences in the debugger. (does .net have a better control?) If anyone can point me in a good direction, I am glad to learn it. I am not sure what to google. I see this difference in behavior (the timer I reference) in the debugger, I am not sure how timing and such works in .net., and or what my best bets are for debugging. A good reference or something to search on would be helpful (converting code written years ago by someone else, but I am getting close :) Thanks to CP for your help to date no-e
-
I checked the ThePrintDocument_PrintPage is called. Thanks for your help, it turns out that a timer in the background fires perfectly every time in the studio and holds me up. Once I run the compiled version it behaves differently. I have got a nice work around. Interesting, being used to VB6 (from which I am converting) I did not see this type of behavior. The app I am converting used the MScomm32 control quite a bit (serial comms) and I would like to better know how VB6 changes relative to .net as I see these differences in the debugger. (does .net have a better control?) If anyone can point me in a good direction, I am glad to learn it. I am not sure what to google. I see this difference in behavior (the timer I reference) in the debugger, I am not sure how timing and such works in .net., and or what my best bets are for debugging. A good reference or something to search on would be helpful (converting code written years ago by someone else, but I am getting close :) Thanks to CP for your help to date no-e
Hi, three comments: 1. for serial communications .NET offers the SerialPort class (starting .NET 2.0). It works fine for me. Warning: its DataReceived event fires on a ThreadPool thread (see #3 below). 2. There are several timer classes in .NET; which one you use best depends on what it needs to do. Example: for Control manipulations (say displaying real time, updating every second) you best use System.Windows.Forms.Timer which ticks on the GUI thread. 3. only the main aka GUI thread is allowed to touch Controls; if you violate this rule strange things are bound to happen. Since you only now told about serial ports and timers, I now suspect it is #3 that is biting you. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.