|
So I have a potential answer in mind for this, and really want to know if this is how real programmer do this... :) So I have a dataGridView bound to a database query. It will end up with anywhere from 0-9 (could be more in theory) rows in it. I want to restrict the size to show say 5, and put scroll bars on if there are more. With teh visual studio interface, I have to set a size for the datagridview, and that size is static, no matter how many items are in it. When there is less then 5 I get the ugly grey area where there are no rows. And yeah I could change the color, but it will still be ugly due to the outline, or it would just be dead space. Also, if you do go over what fits, it then puts a vertical scroll bar in the form, hiding some of the last column, so I woudl be forced to make the datagridview wide enough to accomidate the scrollbar, but when it isn't there... more ugly... I come from a unix background using TK, where you pack things, and they can expand or shrink to fit automatically. I don't see any way to do that with c# and .net. You could also in tk force the vertical scroll bar to be static, so that it is always there, which looks more normal then dead space. For c# and .net, I can add on to the procedure that fills the datagridview and have it resize the datagridview, and the total form, as well as shift other gui objects to accomidate. But that seems like a lot of code for something that is automatic in tk, and seems like something there would be a better way to manage in what is a later language then tk. So anyone know other/better ways to accomplish the same task? Thanks for your time... Randell | | RandellP Thursday, May 07, 2009 3:13 AM | Hi RandellP,
Yes, if you resize the DataGridView, a blank area will be remain on your form and it looks ugly. I have done some research trying to find a solution.
DataGridView blank area is gray and it is not nice. Some of Microsoft products also use DataGridView, You can double click the "Settings.settings" in your project, a big DataGridView is hosted in the form. The blank area is not ugly because it use "System.Drawing.SystemColors.Control" as its backgroundcolor.
I think the way to make your application looks better is change the backgroundcolor of DataGridView. Set the color to be the same as your form's color is the best choice. That's the same way Microsoft use to beautify the Visual Studio.
Sincerely, Kira Qian
Please mark the replies as answers if they help and unmark if they don't. - Marked As Answer byKira QianMSFT, ModeratorWednesday, May 13, 2009 6:15 AM
-
| | Kira Qian Tuesday, May 12, 2009 2:01 AM | Hi RandellP,
First you can set the AutoSizeColumnsMode property to Fill to avoid right gray space. dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
Second, if you want to avoid bottom gray space, you need to resize the DataGridView. You can handle the DataGridView.RowsAdded or RowsRemoved event to calculate the height of DataGridView base on the remain rows.
Does this idea help you?
Sincerely, Kira Qian
Please mark the replies as answers if they help and unmark if they don't. | | Kira Qian Monday, May 11, 2009 3:12 AM | The column one could work... But on the rows, yes I can code in a resize of the datagridview, but I assume I will then have to manually shift everything below it up to absorb the empty space, which will make the program less friendly to future change. So is that what is done normally? Randell | | RandellP Monday, May 11, 2009 2:05 PM | Hi RandellP,
Yes, if you resize the DataGridView, a blank area will be remain on your form and it looks ugly. I have done some research trying to find a solution.
DataGridView blank area is gray and it is not nice. Some of Microsoft products also use DataGridView, You can double click the "Settings.settings" in your project, a big DataGridView is hosted in the form. The blank area is not ugly because it use "System.Drawing.SystemColors.Control" as its backgroundcolor.
I think the way to make your application looks better is change the backgroundcolor of DataGridView. Set the color to be the same as your form's color is the best choice. That's the same way Microsoft use to beautify the Visual Studio.
Sincerely, Kira Qian
Please mark the replies as answers if they help and unmark if they don't. - Marked As Answer byKira QianMSFT, ModeratorWednesday, May 13, 2009 6:15 AM
-
| | Kira Qian Tuesday, May 12, 2009 2:01 AM |
|