How to set up a Windowsforms databound DataGridView such that only x rows are visible?
I need to set up a windows form DataGridView, programmatically bound to a list, such that only 6 rows are visible to the user (i.e. the grid's height is only 6 cells) and a scroll bar appears when there are more than 6 elements in the bound list. All the rows need to be of the same height. Is there a configuration of properties that does this or do I have to manually set the height of the DataGridView so that only 6 rows wou开发者_JAVA技巧ld be visible?
Set the size of the control such that at most 6 rows are visible, and set the Scrollbars property so that the vertical scrollbar appears as needed (to Vertical, or Both if you need a horizontal scrollbar as well).
If I understand your question correctly, you're wanting to use paging on the datagridview. If this is correct try this and this. It's a bit convoluted though.
精彩评论