-
Dec 30th, 2013, 02:52 PM
#1
Thread Starter
Lively Member
Multiple Forms Issue - Remaining on one form
Hello,
I've created two forms - one 'main' and a second 'frmPrint'.
'frmPrint' has a ListBox for the user to select which printer they want to use.
Additionally, the 'defaultPrinter' gets shown/selected in the ListBox while on this form.
I use the .hide, .show and .BringToFront to manage the different forms - this appears to work OK.
But, what techniques do I use to keep on the 'frmPrint' form window until the user: 1) selects
a particular printer from the ListBox (other than the defaultPrinter already selected) and,
2) the user presses the "Select Printer" button on 'frmPrint'?
At that point, I want to return to the 'main' form and continue on with the code there.
Currently, my code completes the ListBox on 'frmPrint' form, selects and highlights the defaultPrinter
then continues back to my main code...essentially back on my 'main' form.
Thanks for any help provided,
Grant
-
Dec 30th, 2013, 02:59 PM
#2
Re: Multiple Forms Issue - Remaining on one form
You might like to trying using frmPrint.Showdialog() to make the form "modal" - the user must deal with the options on frmPrint and cannot click on anything else whilst it is visible. When the form closes, control will pass back to your main form.
-
Dec 30th, 2013, 05:39 PM
#3
Re: Multiple Forms Issue - Remaining on one form
.ShowDialog is indeed the answer but you do realise that there's a ready made couple of Print dialogs sitting in the toolbox?
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Dec 30th, 2013, 06:50 PM
#4
Thread Starter
Lively Member
Re: Multiple Forms Issue - Remaining on one form
Hi Paulg and Dun,
Thanks for the quick response. I'll try out the .ShowDialog and let you know if I was successful.
Dun, Yes, I did try the 'built-in' Print Dialogs but was having trouble with changing from the default printer
to another one I selected. Apparently, either I was doing something wrong (likely) or, there is some sort of bug
with these dialogs as far as not retaining the changed printer settings.
If you have any insight here, I'm open for suggestions!
Thanks again and Regards,
Grant
-
Dec 30th, 2013, 07:16 PM
#5
Thread Starter
Lively Member
Re: Multiple Forms Issue - Remaining on one form
Here's my code for the 'formPrint':
%CODE%
Imports System.Drawing.Printing
'
Public Class formPrint
Private Sub formPrint_Load(sender As Object, e As EventArgs) Handles MyBase.Load
frmMain.Hide()
Me.Show()
Me.BringToFront()
Dim myPrinter As New PrintDocument
Dim Done As Boolean : Done = False
Dim defaultPrinter As String
Dim defaultPrinterIndex As Integer
Me.Text = "Print and PrintPreview Selection Form"
'grab available printers...
For Each strPrinterName As String In PrinterSettings.InstalledPrinters
Me.selectPrinterLstBox.Items.Add(strPrinterName)
Next
Me.selectPrinterLstBox.SelectedItem = myPrinter.DefaultPageSettings.PrinterSettings.PrinterName 'highlight the default printer
defaultPrinter = myPrinter.DefaultPageSettings.PrinterSettings.PrinterName
defaultPrinterIndex = Me.selectPrinterLstBox.SelectedIndex
MsgBox("Selected Item Index = " & Me.selectPrinterLstBox.SelectedIndex & " Default Printer is: " & defaultPrinter)
Me.ShowDialog()
End Sub
%CODE%
The 'Me.ShowDialog()' doesn't appear to change things.
My code blows through this section of code then continues back to my main code that called this via 'formPrint.Show()'.
Grant
-
Dec 30th, 2013, 07:32 PM
#6
Re: Multiple Forms Issue - Remaining on one form
Er .. yeah .. it would. You can't show a form or amend its modality from itself. It would be like me calling myself to dinner! The original call should be amended to formPrint.ShowDialog() on the main form! Only Mums get to call you for dinner!
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|