Build a navigation area for a Datagridview
-
Hello ! Is there any possibility to implement a paging for a winform datagridview ? I like to do this in a similar way like in a webpage , where there's a navigation area in bottom with a Previous button followed by Page numbers and a next button at the end :
<Previous> 1 2 3 4 5 <Next>
Is possible to implement a similar scenario for a Winform Datagridview , so the users can navigate using Previous or Next button , or can access directly a specific page of records clicking on corresponding number. I've seen some models , but all have only Previous and Next buttons only , but not page numbers to access directly a specific page. Thank you !
-
Hello ! Is there any possibility to implement a paging for a winform datagridview ? I like to do this in a similar way like in a webpage , where there's a navigation area in bottom with a Previous button followed by Page numbers and a next button at the end :
<Previous> 1 2 3 4 5 <Next>
Is possible to implement a similar scenario for a Winform Datagridview , so the users can navigate using Previous or Next button , or can access directly a specific page of records clicking on corresponding number. I've seen some models , but all have only Previous and Next buttons only , but not page numbers to access directly a specific page. Thank you !
I've just searched for an implementation like that but I also couldn't find one that not only has buttons for previous, next, first, last but also allows to navigate to a certain page directly. However that will be rather simple to implement. Assuming it shouldn't be a DataGridView in VirtualMode and you choose to use one of those implementations you've found: Look at the code behind the next-button and write a method that does basically the same (repeatedly) but not actually displays the records, just caches the values that are required to display a page. The code behind a page-number-button (or link) should then call the method that displays the page, just like the next-button, but with the cached values of the according page. The solutions I've found: Paging in DataGridView[^] DataGridView With Paging (UserControl)[^] Paging DataGridView in C# using LINQ[^] A Simple Way for Paging in DataGridView in WinForm Applications[^] DataGrid-Paging-C-Windows-Forms[^] Paging Data with DataGridView in VirtualMode[^]
-
I've just searched for an implementation like that but I also couldn't find one that not only has buttons for previous, next, first, last but also allows to navigate to a certain page directly. However that will be rather simple to implement. Assuming it shouldn't be a DataGridView in VirtualMode and you choose to use one of those implementations you've found: Look at the code behind the next-button and write a method that does basically the same (repeatedly) but not actually displays the records, just caches the values that are required to display a page. The code behind a page-number-button (or link) should then call the method that displays the page, just like the next-button, but with the cached values of the according page. The solutions I've found: Paging in DataGridView[^] DataGridView With Paging (UserControl)[^] Paging DataGridView in C# using LINQ[^] A Simple Way for Paging in DataGridView in WinForm Applications[^] DataGrid-Paging-C-Windows-Forms[^] Paging Data with DataGridView in VirtualMode[^]
Thank , but I have the idea about the code I should use. I need help to build a navigation structure. For example , if the number of records in the grid are <= the number of records that the grid can display , the navigation area should be like that :
<Previous> 1 <Next>
Where Previous and Next should be disables. Is user add records and a some point he number of records goes over the number of rows the grid can display , the navigation area should be like this :
<Previous> 1 2 <Next>
where 1 is "clicked" , Next is enable , Previous is disable. The user can remove records , or can add again .....etc. So How can I build a navigation structure that can dynamically change on run time? Thank you !
-
Thank , but I have the idea about the code I should use. I need help to build a navigation structure. For example , if the number of records in the grid are <= the number of records that the grid can display , the navigation area should be like that :
<Previous> 1 <Next>
Where Previous and Next should be disables. Is user add records and a some point he number of records goes over the number of rows the grid can display , the navigation area should be like this :
<Previous> 1 2 <Next>
where 1 is "clicked" , Next is enable , Previous is disable. The user can remove records , or can add again .....etc. So How can I build a navigation structure that can dynamically change on run time? Thank you !
Surely at least one if not all of those half-suitable solutions already include the logic to disable the previous/next-buttons if there are less records than one full page. In that case you would also display the "1" disabled. And if the user adds records you would just have to re-evaluate that disable-condition.
-
Surely at least one if not all of those half-suitable solutions already include the logic to disable the previous/next-buttons if there are less records than one full page. In that case you would also display the "1" disabled. And if the user adds records you would just have to re-evaluate that disable-condition.
Sorry , I need to know what structure and controls should I use : Previous , Next , 1, 2, 3, 4... are buttons ? or something else ? How should I create these buttons on runtime and to position one by one ? ( because the button's number can change ) Of course that the area that I need to use for navigation will be limited , so for example some buttons will be hidden and when the user press next can be visible and the first buttons will be hidden. ( Just like in the navigation in a website ). So I'm asking about the controls that should I use .
-
Sorry , I need to know what structure and controls should I use : Previous , Next , 1, 2, 3, 4... are buttons ? or something else ? How should I create these buttons on runtime and to position one by one ? ( because the button's number can change ) Of course that the area that I need to use for navigation will be limited , so for example some buttons will be hidden and when the user press next can be visible and the first buttons will be hidden. ( Just like in the navigation in a website ). So I'm asking about the controls that should I use .
You could use theoretically any control you like as all controls have a
Click
-Event. Buttons or Labels would probably make the most sense. You should create aUserControl
that encapsulates all the navigation-related controls. Within that UserControl you should use aFlowLayoutPanel
and place the navigation-controls therein. https://msdn.microsoft.com/en-us/library/system.windows.controls.usercontrol%28v=vs.110%29.aspx[^] https://msdn.microsoft.com/en-us/library/system.windows.forms.flowlayoutpanel%28v=vs.110%29.aspx[^] https://www.google.com/search?q=vb.net+winforms+place+controls+runtime&ie=utf-8&oe=utf-8[^]