how to:C# Datagridview must show only fixed number of rows
-
Good day all. This is the first time I ask a question here, but have been using codeproject for some time now. Great site - Good work! Im doing a C# windows forms application that reads data from Windows Sql Server Express and then displays the data from a specific table in a datagridview (im using bindingsource). This is no problem. The problem is my table is quite large more than a thousand rows. Currently all the data displays at one time with vertical scroll bars to scroll down. But I would like to only display a fixed number of rows, say the last 10 entries. Is this at all possible. Hope this question has not been asked before. Searched through a bunch of forums and websites and could not get the right question with an answer. Thanks in advance. Cobus
-
Good day all. This is the first time I ask a question here, but have been using codeproject for some time now. Great site - Good work! Im doing a C# windows forms application that reads data from Windows Sql Server Express and then displays the data from a specific table in a datagridview (im using bindingsource). This is no problem. The problem is my table is quite large more than a thousand rows. Currently all the data displays at one time with vertical scroll bars to scroll down. But I would like to only display a fixed number of rows, say the last 10 entries. Is this at all possible. Hope this question has not been asked before. Searched through a bunch of forums and websites and could not get the right question with an answer. Thanks in advance. Cobus
Sorry to answer my own question, but I found a solution: Instead of using the datagridview to show only the newest 10 entries I changed my SQL Query which will fill my datatable to:
SELECT TOP 10 Column1,Column2
FROM Table_Name
ORDER BY Column1 DESCThis result is then the 10 most recent entries in the table. Without the DESC keyword the first 10 entries will be displayed Thank you in any case.
-
Sorry to answer my own question, but I found a solution: Instead of using the datagridview to show only the newest 10 entries I changed my SQL Query which will fill my datatable to:
SELECT TOP 10 Column1,Column2
FROM Table_Name
ORDER BY Column1 DESCThis result is then the 10 most recent entries in the table. Without the DESC keyword the first 10 entries will be displayed Thank you in any case.
Cobusvdvyver wrote:
Sorry to answer my own question, but I found a solution:
Its never a bad thing to answer your own question, it shows you are working and not just waiting for the codz to be sent to you. Also feedback on the solution may help another and stops those who help from spending resources on an answered question. So have 5 and keep it up.
Never underestimate the power of human stupidity RAH