datagridview top ten-VBForums
Results 1 to 6 of 6

Thread: datagridview top ten

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2017
    Posts
    19

    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.
    Attached Images Attached Images  

  2. #2
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,123

    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. #3

    Thread Starter
    Junior Member
    Join Date
    May 2017
    Posts
    19

    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.
    Thank you very much for your answer.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    May 2017
    Posts
    19

    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. #5
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,123

    Re: datagridview top ten

    Quote Originally Posted by curiousman View Post
    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. #6

    Thread Starter
    Junior Member
    Join Date
    May 2017
    Posts
    19

    Re: datagridview top ten

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

Tags for this Thread

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


Click Here to Expand Forum to Full Width

Survey posted by VBForums.