|
Any example for how to place a picture in the printing document?
Thanks Very Much
|
|
|
|
|
In the documentation, the section "DGVPrinter Image Properties" has the Image API and an example of placing an image in the printed area.
Steve G.
|
|
|
|
|
Thank U, I solved my issue!
|
|
|
|
|
Is it possible to scale the image
|
|
|
|
|
DGVPrinter doesn't have the ability to scale an embedded image.
Steve G.
|
|
|
|
|
aureolin, thank you for the excellent code. is a question which parameter is responsible for all the columns fit the width of the sheet in one?
picture print by default
http://img254.imageshack.us/img254/1185/dgvprint.png[^]
that is, if I stretch window to full screen, and since DataGridView align it to the window, and print what is given in the picture
http://img850.imageshack.us/img850/8571/dgvprinttest2.png[^]
How fixed?
settings:
Dim Printer = New DGVPrinter
Printer.Title = "TEST"
Printer.SubTitle = FormatDateTime(Date.Today, DateFormat.LongDate)
Printer.SubTitleFormatFlags = StringFormatFlags.LineLimit Or StringFormatFlags.NoClip
Printer.PageNumbers = True
Printer.PageNumberInHeader = False
Printer.ColumnWidth = DGVPrinter.ColumnWidthSetting.Porportional
Printer.HeaderCellAlignment = StringAlignment.Near
Printer.Footer = "TESTTESTEST"
Printer.FooterSpacing = 15
Printer.PrintDataGridView(Me.dgv_prih)
modified 12-Nov-12 1:06am.
|
|
|
|
|
The setting that controls this is the "ColumnWidth" setting. You've set it to "Porportional", which will stretch the columns to fill the page. The other settings are "DataWidth" which will scale the column widths to fit the data, and "CellWidth" which will reflect the current display column widths to the printout. You can also set individual column widths to fixed values to help 'adjust' the printout to look the way you want it to.
Steve G.
|
|
|
|
|
Old ver.
gives me :A generic error occurred in GDI+.
Ver 4.2
gives me :Fixed row exceeds width error or something like this.
Help Please
|
|
|
|
|
???
I think I'm going to need more information. What was the specific error and where did it occur? Which of the available print methods were you using (assuming this error occurred during printing)?
Steve G.
|
|
|
|
|
I am sorry I thought I was clear ,
The error occurs when I tried to Print and preview DGV ofcourse
Printer.PrintPreviewDataGridView(DataGridView1)
The weird thing is the dgv was in separate form it was printing normally
when I put it inside tabcontrol tabpage the error appears just before the preview window shows up
A generic error occurred in GDI+.
I downloaded last ver 4.2 and I got now new error also on printing the dgv which I told you earlier.
modified 8-Nov-12 17:49pm.
|
|
|
|
|
I found the cause of this error.
It is not related to tab control or tab page.
I found that the selected printer is set to Microsoft OneNote ,once I changed it to normal printer the error is gone.
Sorry If I bothered you .
|
|
|
|
|
Not a problem.
Steve G.
|
|
|
|
|
Excellent piece of work. But how do you change the title, subtitle, & footer properties (e.g., bold, size, etc.)? Tks, OH
|
|
|
|
|
Methods to do this start on pg. 10 of the documentation. And, you just made me realize that I neglected to number the pages in the documentation. Heh - one more item for the next revision.
Steve G.
|
|
|
|
|
Welll, it wasn't exactly obvious that that was documentation. I was expecting something different and didn't exactly know that I had to do it as follows:
Printer.TitleFont = New Font("Tacoma", 14, FontStyle.Regular)
Maybe a snippet of code for each property would be illustrative (for us folks that are still trying to get our arms around this beast (VB.Net)). However, I am impressed that there is even 'documentation'.
But indeed it does work. Tks, OH
|
|
|
|
|
Dear author,
is it possible somehow to add a row number for each row to the printed page? I know, that i can add a column with this information, but i think, that more people would appretiate, if this functionallity would be built-in.
Example
I have grid with this data
Jane Doe
Joe Doe
I would like to have on the printed page
1 Jane Doe
2 Joe Doe
If it is possible to do it know somehow, please let me know. Thank you and great job!
|
|
|
|
|
Had to think about this one for a while. At this point, I don't see this as a feature that fits within what DGVPrinter is trying to do. That said, this is a very creative and interesting suggestion - it really made me think!
Thanks for the suggestion -
Steve G.
|
|
|
|
|
I believe it's "Proportional" not "Porportional".
Otherwise, your code was really easy to just plug-in and go.
Ryan C. Price
|
|
|
|
|
Hmm... learn something new every day.
Thanks!
Steve G.
|
|
|
|
|
Hi
I'm using your lovely dll in a project I'm working on to print a datagridview using the simply version. My c++/cli coding uses:
DGVPrinter printer;
printer.Title = "A Title";
printer.PorportionalColumns = true;
printer.PageNumbers = true;
printer.PageNumberInHeader = false;
printer.Footer = "footer";
printer.FooterSpacing = 15;
printer.PrintDataGridView(dgvsheet);
and it works fine EXCEPT that I need the rows to be at a greater height. I was hoping the line I needed went:
printer.RowHeight =
but I've absolutely no idea what would come next.
Can I do this and, if so, how?
Brian
|
|
|
|
|
The easiest and simplest way to do this is to alter the row heights in your grid, and then tell the printer object to use the "CellHeights" setting. In C# this would be:
printer.RowHeight = DGVPrinter.RowHeightSetting.CellHeight;
If you find that the data in the cell just isn't "fitting" then use "DataHeight" instead of "CellHeight".
What I'm not sure of is how you would gain access the enum "RowHeightSetting" in c++. I mention this as someone mentioned having issues with the enums in C++ in a recent post.
The issue with just setting the row heights is that DGVPrinter does a lot of calculation to determine the row heights (given that you can change fonts, etc.) to try to ensure that the data in the cells will show in the printout, and to know when to insert page breaks.
Hope this helps,
Steve G.
|
|
|
|
|
Thanks for that feedback.
I don't suppose you remember who/when enum was mentioned do you? I ask as a search didn't find anything.
nz556
|
|
|
|
|
Hi again Steve,
Another minor problem - updated to your latest version and my code line of:
printer.PrintSettings.DefaultPageSettings.Landscape = true;
isn't working anymore. Has this been changed?
Joe
|
|
|
|
|
"Nothing has changed" - however, this is the second recent report of something fishy with landscape printing. I'm going to take a look into this and see if I can find anything. Can you send some more details on what you're doing to help me track this down?
Thanks,
Steve G.
|
|
|
|
|
Thanks Steve,
I am pressing a toolstrip button to process the following event (listed in full below):
private void printToolStripButton_Click(object sender, EventArgs e)
{
DGVPrinter printer = new DGVPrinter();
printer.SubTitleFormatFlags = StringFormatFlags.LineLimit |
StringFormatFlags.NoClip;
printer.ColumnStyles[rentalPrintGridView.Columns[0].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[0].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[0].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnStyles[rentalPrintGridView.Columns[0].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[0].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[0].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[0].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[0].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[1].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[1].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[1].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnStyles[rentalPrintGridView.Columns[1].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[1].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[1].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[1].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[1].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[2].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[2].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[2].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnWidths.Add(rentalPrintGridView.Columns[2].Name, 55);
printer.ColumnStyles[rentalPrintGridView.Columns[2].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[2].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[2].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[2].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[2].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[3].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[3].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[3].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnWidths.Add(rentalPrintGridView.Columns[3].Name, 25);
printer.ColumnStyles[rentalPrintGridView.Columns[3].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[3].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[3].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[3].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[3].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[4].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[4].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[4].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnWidths.Add(rentalPrintGridView.Columns[4].Name, 30);
printer.ColumnStyles[rentalPrintGridView.Columns[4].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[4].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[4].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[4].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[4].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[5].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[5].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[5].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnWidths.Add(rentalPrintGridView.Columns[5].Name, 75);
printer.ColumnStyles[rentalPrintGridView.Columns[5].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[5].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[5].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[5].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[5].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[6].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[6].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[6].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnWidths.Add(rentalPrintGridView.Columns[6].Name, 50);
printer.ColumnStyles[rentalPrintGridView.Columns[6].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[6].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[6].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[6].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[6].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[7].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[7].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[7].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnWidths.Add(rentalPrintGridView.Columns[7].Name, 50);
printer.ColumnStyles[rentalPrintGridView.Columns[7].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[7].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[7].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[7].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[7].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[8].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[8].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[8].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnWidths.Add(rentalPrintGridView.Columns[8].Name, 25);
printer.ColumnStyles[rentalPrintGridView.Columns[8].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[8].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[8].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[8].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[8].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[9].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[9].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[9].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnWidths.Add(rentalPrintGridView.Columns[9].Name, 50);
printer.ColumnStyles[rentalPrintGridView.Columns[9].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[9].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[9].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[9].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[9].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[10].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[10].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[10].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnWidths.Add(rentalPrintGridView.Columns[10].Name, 125);
printer.ColumnStyles[rentalPrintGridView.Columns[10].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[10].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[10].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[10].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[10].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[11].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[11].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[11].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnWidths.Add(rentalPrintGridView.Columns[11].Name, 50);
printer.ColumnStyles[rentalPrintGridView.Columns[11].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[11].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[11].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[11].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[11].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[12].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[12].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[12].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnWidths.Add(rentalPrintGridView.Columns[12].Name, 50);
printer.ColumnStyles[rentalPrintGridView.Columns[12].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[12].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[12].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[12].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[12].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[13].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[13].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[13].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnWidths.Add(rentalPrintGridView.Columns[13].Name, 50);
printer.ColumnStyles[rentalPrintGridView.Columns[13].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[13].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[13].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[13].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[13].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[14].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[14].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[14].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnWidths.Add(rentalPrintGridView.Columns[14].Name, 40);
printer.ColumnStyles[rentalPrintGridView.Columns[14].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[14].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[14].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[14].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[14].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[15].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[15].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[15].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnWidths.Add(rentalPrintGridView.Columns[15].Name, 75);
printer.ColumnStyles[rentalPrintGridView.Columns[15].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[15].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[15].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[15].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[15].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[16].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[16].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[16].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnWidths.Add(rentalPrintGridView.Columns[16].Name, 125);
printer.ColumnStyles[rentalPrintGridView.Columns[16].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[16].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[16].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[16].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[16].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnStyles[rentalPrintGridView.Columns[17].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnStyles[rentalPrintGridView.Columns[17].Name].Font = new Font("Arial", (float)5.5);
printer.ColumnStyles[rentalPrintGridView.Columns[17].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnWidths.Add(rentalPrintGridView.Columns[17].Name, 125);
printer.ColumnStyles[rentalPrintGridView.Columns[17].Name].WrapMode = DataGridViewTriState.True;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[17].Name] = rentalPrintGridView.DefaultCellStyle.Clone();
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[17].Name].Font = new Font("Arial", (float)5.5, FontStyle.Bold);
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[17].Name].Alignment = DataGridViewContentAlignment.MiddleCenter;
printer.ColumnHeaderStyles[rentalPrintGridView.Columns[17].Name].WrapMode = DataGridViewTriState.True;
string EffDateStart = Convert.ToString(startDateToolStripTextBox.Text);
string EffDateFinish = Convert.ToString(endDateToolStripTextBox.Text);
string Code1 = Convert.ToString(code1ToolStripTextBox.Text);
string Code2 = Convert.ToString(code2ToolStripTextBox.Text);
string Code3 = Convert.ToString(code3ToolStripTextBox.Text);
string Street1 = Convert.ToString(street1ToolStripTextBox.Text);
string Suburb1 = Convert.ToString(suburb1ToolStripTextBox.Text);
string Suburb2 = Convert.ToString(suburb2ToolStripTextBox.Text);
printer.PageNumbers = true;
printer.PageNumberInHeader = false;
printer.PorportionalColumns = true;
printer.HeaderCellAlignment = StringAlignment.Near;
printer.Title = "S&P Rental Database";
printer.SubTitle = "Effective Date: " + EffDateStart + " - " + EffDateFinish + ", Code: " + Code1 + " " + Code2 + " " + Code3 + ", Street: " + Street1 + ", Suburb: " + Suburb1 + " " + Suburb2;
printer.Footer = "Saunders & Pitt";
printer.FooterSpacing = 15;
printer.PrintSettings.DefaultPageSettings.Landscape = true;
printer.PrintDataGridView(rentalPrintGridView);
}
That is using the older version of DGVPrinter and it works as it should. When I change it to the most recent version, everything works except default page layout is portrait. I have made no other changes except updating class file.
Joe
|
|
|
|
|