Modify the number of rows that a datagridview can show instantly , on runtime
-
Hello ! Is there any possibility to modify the number of rows that a datagridview can show instantly ? For example a datagridview can show 12 record instantly. On runtime , is possible to make a modifications in order that the datagridview to show 10 records instantly ( the remaining datagridview area can be empty ). Thank you !
-
Hello ! Is there any possibility to modify the number of rows that a datagridview can show instantly ? For example a datagridview can show 12 record instantly. On runtime , is possible to make a modifications in order that the datagridview to show 10 records instantly ( the remaining datagridview area can be empty ). Thank you !
What do you mean by "can show instantly"? The vertical size of the DataGridView?
-
What do you mean by "can show instantly"? The vertical size of the DataGridView?
-
I mean can show together in one page. I want to modify this number ( but without changing the datagridview vertical size. )
If you don't use the DataGridView in databound-mode then you can set the number of rows displayed with its
.RowCount
-property. In databound-mode that is not possible. -
If you don't use the DataGridView in databound-mode then you can set the number of rows displayed with its
.RowCount
-property. In databound-mode that is not possible. -
If you want to restrict the amount of rows in databound-mode then you have to restrict the amount of rows in the datasource. If your datasource is a DataView of a DataTable with some integer as primary key (or just any unique integer column) you could use the
.RowFilter
-property of the DataView to filter from the total rows the rows that should currently be displayed, e.g.:dataView.RowFilter = "idColumn >= 10 AND idColumn < 20"
If the values of that column aren't consecutive you would have to scan the rows before and determine the actual value of that column at the position that should be the last on the page.
-
If you want to restrict the amount of rows in databound-mode then you have to restrict the amount of rows in the datasource. If your datasource is a DataView of a DataTable with some integer as primary key (or just any unique integer column) you could use the
.RowFilter
-property of the DataView to filter from the total rows the rows that should currently be displayed, e.g.:dataView.RowFilter = "idColumn >= 10 AND idColumn < 20"
If the values of that column aren't consecutive you would have to scan the rows before and determine the actual value of that column at the position that should be the last on the page.
-
If a apply a filter , then the vertical scrollbar will be hide , and the user may think that there are no more records in the gridview.
The vertical scrollbar doesn't hide when applying a filter, unless the filter restricts the amount of rows to less than the height of the DataGridView. If that's not true for your DataGridView the reason must be somewhere else.
-
The vertical scrollbar doesn't hide when applying a filter, unless the filter restricts the amount of rows to less than the height of the DataGridView. If that's not true for your DataGridView the reason must be somewhere else.
Yes , but if you read my first post , this is what I want t o do. Actually gridview has for example , 36 records and he show 12 records per page. I want to reduce this number for example to 10. but the total height of 10 records is less than gridview height , so if I apply a filter to show 10 records , the vertical scrollbar will be hidden.
-
Yes , but if you read my first post , this is what I want t o do. Actually gridview has for example , 36 records and he show 12 records per page. I want to reduce this number for example to 10. but the total height of 10 records is less than gridview height , so if I apply a filter to show 10 records , the vertical scrollbar will be hidden.
Alright, but what would a visible scrollbar change about the user possibly thinking that there are no more records when he scrolls to the end but in fact there are still more records? You will have to indicate that by something better than a scrollbar. Didn't you want to display something like <prev> 1 2 3 4 5 <next>? That would inform the user about more records.
-
Alright, but what would a visible scrollbar change about the user possibly thinking that there are no more records when he scrolls to the end but in fact there are still more records? You will have to indicate that by something better than a scrollbar. Didn't you want to display something like <prev> 1 2 3 4 5 <next>? That would inform the user about more records.
the reason why I want this behavior , is because sometimes the last record on a page is not full displayed. So the gridview shows 12 , but the last record is not full displayed. so I want to reduce the number to 11 or 10. I know that I can make this by changing the gridview's height on design to full display the last record, but on runtime the user can resize the row's height so will be the same situation
-
the reason why I want this behavior , is because sometimes the last record on a page is not full displayed. So the gridview shows 12 , but the last record is not full displayed. so I want to reduce the number to 11 or 10. I know that I can make this by changing the gridview's height on design to full display the last record, but on runtime the user can resize the row's height so will be the same situation
But what would be the use of a visible ScrollBar if there is nothing to scroll? My advice would be: Do whatever you want with the amount of records displayed but don't bother with the scrollbar. If it's needed for scrolling, it will be shown, otherwise not. If there are more records than on the current page, inform the user by showing the page-selection-controls. If you absolutely want to have an always visible scrollbar you will have to do some extra work: https://social.msdn.microsoft.com/forums/windows/en-us/516851de-ac00-4442-b846-44734dcbd7f5/always-display-vertical-scrollbar-in-datagridview[^]
-
the reason why I want this behavior , is because sometimes the last record on a page is not full displayed. So the gridview shows 12 , but the last record is not full displayed. so I want to reduce the number to 11 or 10. I know that I can make this by changing the gridview's height on design to full display the last record, but on runtime the user can resize the row's height so will be the same situation