1. ## datagridview top ten

Hi friends;

I have a datagridview like attachment. How can I find the ten biggest and ten smallest numbers in column A, and write them in column B. (from the first cell)
Thanks a lot.

2. ## Re: datagridview top ten

Copy the values to a temporary numeric array (not a String array). It may be easier to copy from the original data source rather than from the DataGridView cells; depends on how you originally populated the DGV.

Use the Array.Sort method on the temporary array and pick the first ten and last ten values from the sorted array.

3. ## Re: datagridview top ten

OK. May be a solution but not for me I think. Because, I will add new row cell everyday. And if you think that I have many columns like that it will be very hard to do same everyday.

4. ## Re: datagridview top ten

In my opinion we can solve this problem in that way. Look at the first cell of the first column. Its value is 9 and Its address is ***DataGridView1.Rows(0).Cells(0).Value****. The last cell value is 7,55 and its address is ***DataGridView1.Rows(43).Cells(0).Value****. So, if it is possible to find where the first empyt cell is in the first column (let say between DataGridView1.Rows(0).Cells(0).Value and DataGridView1.Rows(220).Cells(0).Value) , it will be easy to write the code for upper cells and to calculate the average.

5. ## Re: datagridview top ten

Originally Posted by curiousman
In my opinion we can solve this problem in that way. Look at the first cell of the first column. Its value is 9 and Its address is ***DataGridView1.Rows(0).Cells(0).Value****. The last cell value is 7,55 and its address is ***DataGridView1.Rows(43).Cells(0).Value****. So, if it is possible to find where the first empyt cell is in the first column (let say between DataGridView1.Rows(0).Cells(0).Value and DataGridView1.Rows(220).Cells(0).Value) , it will be easy to write the code for upper cells and to calculate the average.
Sounds like a plan. So what are you stuck on?

6. ## Re: datagridview top ten

Originally Posted by Inferrd
Sounds like a plan. So what are you stuck on?
I know the way but not how to go

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

Featured