Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the code found here to print my windows form datagrid. My question that I have is how can I make the row height greater than the default height?

It doesn't look like it showed my link, so here it is:
Another DataGridView Printer[^]
Posted
Updated 2-Apr-13 8:57am
v3
Comments
Kenneth Haugland 2-Apr-13 14:50pm    
And this is WinForms or?
FoxTrotCharlie 2-Apr-13 14:56pm    
Sorry, yes this is for a windows form.
Kenneth Haugland 2-Apr-13 14:57pm    
Well, cant help you there, but fixed the tag for you :-)
FoxTrotCharlie 2-Apr-13 14:59pm    
Apologies for the incorrect tag, but thank you for updating!
Kenneth Haugland 2-Apr-13 15:02pm    
No problem. I could help you in WPF but not WinForms. I skipped WinForms and went straight for WPF.

I actually just discovered how to set the row height for a datagrid. I used this code:

dgvScheduler.RowTemplate.MinimumHeight = 30;
//And just set the Height to whatever value you are after!
 
Share this answer
 
It seems to be simple to achieve:
C#
printer.RowHeight = DGVPrinter.RowHeightSetting.CellHeight;


Please, follow the link to the article, go to the end of it to find Comments and Discussion section. There ask a question ;)

You can use DataGridViewRow.Height[^] or DataGridViewRow.MinimumHeight[^] property too.

C#
DataGridViewRow row = dataGridView.Rows[0];
row.Height = 15;
//or
DataGridViewRow row = dataGridView.Rows[1];
row.MinimumHeight = 40;
 
Share this answer
 
v2
Comments
FoxTrotCharlie 2-Apr-13 15:40pm    
I saw that piece, but I thought I would have to actually set the height. Like CellHeight = 32;

Should I close this question and post in the QNA of the thread I linked back to? Is that the proper protocol?
Maciej Los 2-Apr-13 15:47pm    
Not necessary, but it's better to ask author of article...
See my updated answer.
FoxTrotCharlie 2-Apr-13 15:58pm    
Does that element of coding go in my DataGrid load event?

When I attempt to use my datagrid I get a compile error of dgvScheduler is a 'field' but is used like a 'type'

This is the syntax I used:
dgvScheduler row = dgvScheduler.Rows[0];
row.Height = 15;
Maciej Los 2-Apr-13 16:09pm    
NOT dgvScheduler row = dgvScheduler.Rows[0], but DataGridViewRow row = dgvScheduler.Rows[0]
Do you see the difference?
FoxTrotCharlie 2-Apr-13 16:27pm    
I do see the difference. Thank you for pointing that out. I get a debug error of Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900