Datagridview not changing size when changed from landscape to porttrait?
-
I have a application setup as Spreadsheet to display and print a datagridview. My problem is if I start the application, load a file, change the pagesetup to landscape, then print either to printer or preview it will print correctly. Now if I change back to portrait the preview or print out does change to the new setting. The displayed or printed data does not resize. The data is printed of the page. This works both ways if I start with portrait the same thing happens except the data in landscape is small on the page. Below is the code I use for printing and datagridview. I have tried several things including refresh and invalidate but nothing has had an affect. The only way I have found to change is to stop and restart the application in debug. <pre> Private Sub PrintDocument_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintDocument.Click PrintDialog1.AllowSomePages = True ' Show the help button. PrintDialog1.ShowHelp = True PrintDialog1.Document = PrintDocument1 Dim result As DialogResult = PrintDialog1.ShowDialog() ' If the result is OK then print the document. If (result = DialogResult.OK) Then PrintDocument1.Print() End If End Sub Private Sub PrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreview.Click Me.Refresh() DataGridView1.RefreshEdit() Dim dlg As New PrintPreviewDialog() Dim d dlg.Document = PrintDocument1 d = PrintDocument1.DefaultPageSettings PrintDocument.Invalidate() dlg.ShowDialog() End Sub Private Sub PageSetup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PageSetup.Click PageSetupDialog1.Document = PrintDocument1 PageSetupDialog1.AllowOrientation = True ' Sets the print document's color setting to false, ' so that the page will not be printed in color. 'PageSetupDialog1.Document.DefaultPageSettings.Color = False PageSetupDialog1.ShowDialog() If PageSetupDialog1.Document.DefaultPageSettings.Landscape = False Then PrintDocument1.DefaultPageSettings.Landscape = False End If If PageSetupDialog1.Document.DefaultPageSettings.Landscape = True Then PrintDocument1.DefaultPageSettings.Landscape = True End If PageSetupDialog1.PrinterSettings = End Sub Private Sub
-
I have a application setup as Spreadsheet to display and print a datagridview. My problem is if I start the application, load a file, change the pagesetup to landscape, then print either to printer or preview it will print correctly. Now if I change back to portrait the preview or print out does change to the new setting. The displayed or printed data does not resize. The data is printed of the page. This works both ways if I start with portrait the same thing happens except the data in landscape is small on the page. Below is the code I use for printing and datagridview. I have tried several things including refresh and invalidate but nothing has had an affect. The only way I have found to change is to stop and restart the application in debug. <pre> Private Sub PrintDocument_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintDocument.Click PrintDialog1.AllowSomePages = True ' Show the help button. PrintDialog1.ShowHelp = True PrintDialog1.Document = PrintDocument1 Dim result As DialogResult = PrintDialog1.ShowDialog() ' If the result is OK then print the document. If (result = DialogResult.OK) Then PrintDocument1.Print() End If End Sub Private Sub PrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreview.Click Me.Refresh() DataGridView1.RefreshEdit() Dim dlg As New PrintPreviewDialog() Dim d dlg.Document = PrintDocument1 d = PrintDocument1.DefaultPageSettings PrintDocument.Invalidate() dlg.ShowDialog() End Sub Private Sub PageSetup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PageSetup.Click PageSetupDialog1.Document = PrintDocument1 PageSetupDialog1.AllowOrientation = True ' Sets the print document's color setting to false, ' so that the page will not be printed in color. 'PageSetupDialog1.Document.DefaultPageSettings.Color = False PageSetupDialog1.ShowDialog() If PageSetupDialog1.Document.DefaultPageSettings.Landscape = False Then PrintDocument1.DefaultPageSettings.Landscape = False End If If PageSetupDialog1.Document.DefaultPageSettings.Landscape = True Then PrintDocument1.DefaultPageSettings.Landscape = True End If PageSetupDialog1.PrinterSettings = End Sub Private Sub
No one is going to read this unformatted garbage. Fix the formatting and only post what is necessary, not all of the code in your app.
I know the language. I've read a book. - _Madmatt
-
No one is going to read this unformatted garbage. Fix the formatting and only post what is necessary, not all of the code in your app.
I know the language. I've read a book. - _Madmatt
Since you don't like the way it's posted fix your dam editor I used the code block to insert. bye will not re post will ask on MSBN
-
Since you don't like the way it's posted fix your dam editor I used the code block to insert. bye will not re post will ask on MSBN
You do know that it's not his editor don't you?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
Since you don't like the way it's posted fix your dam editor I used the code block to insert. bye will not re post will ask on MSBN
Curtis Underwood wrote:
will ask on MSBN
I don't think the Minnesota Sports Broadcasting Network[^] will be of much use either.
I know the language. I've read a book. - _Madmatt
-
Curtis Underwood wrote:
will ask on MSBN
I don't think the Minnesota Sports Broadcasting Network[^] will be of much use either.
I know the language. I've read a book. - _Madmatt
MSDN Hit wrong key. But the editor still caused the problem. Since it did not display the code the way it is in Visual Studio. I will not spend two or three days trying to get it to display the code to your liking. I wrapped the code in the pre tags. I don't have the time to try to figure out whats wrong with this editor. This
-
You do know that it's not his editor don't you?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
Yes I know its not his editor but he told me several thing such as to not post as much code well ok I won't post any Because without the code that I am using how can he tell where the problem is. I did not post anymore code than I thought was necessary all it contained was the datagridview and the print set up routine. If he did not need that then he should be able to answer the question without the code at all. But I was not thinking of him when I posted it. I was thinking of the beginners that try to follow what is going on, with out the code their lost. Besides what portion am I supposed to post. The whole thing is interlaced with setup calls. This is a problem that is caused by logic not caused by something that is just not getting the data. To troubleshoot logic you have to have the code.