Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Getting rid of empty space below the last row in DataGridView?
 

Getting rid of empty space below the last row in DataGridView?

There is an empty space between the last row and the bottom of the datagridview.
Is there a way to get rid of this?

http://cid-e9f285e03800bd81.skydrive.live.com/self.aspx/Public/datagridview%7C_blankspace.JPG

It's the dark area below the last row.
doughboy  Wednesday, August 26, 2009 7:46 PM
Hi doughboy,

Through DataGridView cannot trim the below dark area. But to make it looks prettier, you can set its BackgroundColor to "System.Drawing.SystemColors.Control". So the dark area will become the same color as your control.

Like this
this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Control;

Does this meet your need?

Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Friday, August 28, 2009 7:18 AM
Christoph Wagner  Thursday, August 27, 2009 5:50 AM
Christoph Wagner  Thursday, August 27, 2009 5:50 AM
so it looks like they fixed the integral row height issue by only showing integral rows and hiding the partial row. In my case, I want the partial row!
Looks like they closed the ticket as By Design. Great.
DGV shows partial columns so why not partial rows?
Anyway, thanks for the link
doughboy  Thursday, August 27, 2009 2:16 PM
Hi doughboy,

Through DataGridView cannot trim the below dark area. But to make it looks prettier, you can set its BackgroundColor to "System.Drawing.SystemColors.Control". So the dark area will become the same color as your control.

Like this
this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Control;

Does this meet your need?

Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Friday, August 28, 2009 7:18 AM
Setting the background color isn't really going to help in my case but that's a good idea.
doughboy  Tuesday, September 01, 2009 5:09 PM
Why not size the datagridview accordingly. You can get the height of the column headers, row height and set the minimum size equal to the sum of those two and the maximum size equal to the sum of the column header size and the row height times the max number of rows you want to display. You will of course have to adjust for border widths and such but that's not too difficult.
If at first you don't succeed, don't try sky diving !!!
JF Sohm  Tuesday, September 15, 2009 5:44 PM

You can use google to search for other answers

Custom Search

More Threads

• Creating lists (or playlists) from a DataTable
• Many-To-Many relation and showing all record
• DataGridView automatically selects first row after 60 seconds of inactivity
• check dataset for changes
• Getting Dataset information behind Datagrid Row
• Connection pool timing out
• DataGridView CurrendRow Cells["ByName"] Access by Name or by Index
• Identifying the operation done on Datarow????
• Selected Item in Datagridviewcomboboxcell
• Graphic artifacts when horizontally scrolling DataGridView